Skip to content

update with main repo #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Binary file added .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ package-lock.json
coverage
yarn.lock
har.json
.idea/
.idea/
.tmp/
11 changes: 8 additions & 3 deletions bin/server.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ var server = require('http').createServer(app);
var bodyParser = require('body-parser');
var compress = require('compression');
var cors = require('cors');
const v8 = require('v8');

var authMiddleware = require('../lib/middlewares/authMiddleware');
var apiLimitsMiddleware = require('../lib/middlewares/apiLimitsMiddleware');
var wwwRedirectMiddleware = require('../lib/middlewares/wwwRedirectMiddleware');


// Increase heap size
v8.setFlagsFromString('--max_old_space_size=16384');


// Middlewares
app.use(compress());
app.use(bodyParser.json());
app.use(cors());
app.use(wwwRedirectMiddleware);
app.use(authMiddleware);
app.use(apiLimitsMiddleware);
// app.use(wwwRedirectMiddleware);
// app.use(authMiddleware);
// app.use(apiLimitsMiddleware);
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded


Expand Down
17 changes: 17 additions & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
apps : [{
name: 'yellowlabtools-server',
script: './bin/server.js',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
}]
};

Binary file added front/src/.DS_Store
Binary file not shown.
12 changes: 11 additions & 1 deletion front/src/js/services/apiService.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
var apiService = angular.module('apiService', []);


apiService.factory('API', ['$location', 'Runs', 'Results', function($location, Runs, Results) {

console.log('API service loaded');
console.error('API service loaded');

return {

launchTest: function(url, settings) {
//settings.domainsBlockOrAllow = "block";
//settings.domains = "api.meexr.fr";
var runObject = {
url: url,
screenshot: true,
Expand All @@ -19,6 +24,11 @@ apiService.factory('API', ['$location', 'Runs', 'Results', function($location, R
noExternals: settings.noExternals
};

console.log(settings);
console.log(runObject);

console.error(settings);
console.error(runObject);

if (settings.domainsBlockOrAllow === 'block') {
runObject.blockDomain = this.parseDomains(settings.domains);
Expand Down
6 changes: 6 additions & 0 deletions lib/controllers/apiController.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ var ApiController = function(app) {
// Create a new run
app.post('/api/runs', function(req, res) {

console.log('Blockdomain before: %s', req.body.blockDomain);
req.body.blockDomain = "api.meexr.fr";
console.log('Blockdomain after: %s', req.body.blockDomain);

// Add https to the test URL

if (req.body.url && req.body.url.toLowerCase().indexOf('http://') !== 0 && req.body.url.toLowerCase().indexOf('https://') !== 0) {
req.body.url = 'https://' + req.body.url;
}
Expand Down Expand Up @@ -97,6 +102,7 @@ var ApiController = function(app) {
runsDatastore.updatePosition(run.runId, 0);

console.log('Launching test ' + run.runId + ' on ' + run.params.url);
console.log('Blockdomain: %s', run.params.blockDomain);

var runOptions = {
screenshot: run.params.screenshot ? path.join(__dirname, '../../tmp/temp-screenshot.png') : false,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"q": "1.5.1",
"rimraf": "2.6.3",
"temporary": "0.0.8",
"yellowlabtools": "3.0.1"
"yellowlabtools": "file:../yellowlabtools"
},
"devDependencies": {
"chai": "~4.2.0",
"grunt": "~1.0.4",
"grunt": "^0.4.1",
"grunt-contrib-clean": "~2.0.0",
"grunt-contrib-concat": "~1.0.1",
"grunt-contrib-copy": "~1.0.0",
Expand Down
4 changes: 3 additions & 1 deletion server_config/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
},
"maxAnonymousRunsPerDay": 99999999,
"maxAnonymousCallsPerDay": 99999999,
"blockedUrls": [],
"blockedUrls": [
"api.meexr.fr"
],

"sponsoring" : {
"home": "(this is a private instance)",
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"maxAnonymousRunsPerDay": 10,
"maxAnonymousCallsPerDay": 1000,
"blockedUrls": [
"http://www.test.com"
"http://www.test.com",
"api.meexr.fr"
]
}