From 4e29d5cbea558f7839bf2c55f4736ef3738209b7 Mon Sep 17 00:00:00 2001 From: Vincent L Date: Wed, 18 May 2016 20:20:09 +0200 Subject: [PATCH 1/3] Update apiController.js Fix bad request with curl $ curl -X POST --data "url=perdu.com" http://localhost:8383/api/runs/ Bad request $ curl -X POST --data "url=perdu.com" http://localhost:8383/api/runs/ Moved Temporarily. Redirecting to /api/results/eesudz6s7n --- lib/server/controllers/apiController.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/server/controllers/apiController.js b/lib/server/controllers/apiController.js index 952932d..49ab41b 100644 --- a/lib/server/controllers/apiController.js +++ b/lib/server/controllers/apiController.js @@ -7,7 +7,7 @@ var RunsQueue = require('../datastores/runsQueue'); var RunsDatastore = require('../datastores/runsDatastore'); var ResultsDatastore = require('../datastores/resultsDatastore'); var serverSettings = require('../../../server_config/settings.json'); - +var bodyParser = require('body-parser'); var ApiController = function(app) { 'use strict'; @@ -16,7 +16,7 @@ var ApiController = function(app) { var runsDatastore = new RunsDatastore(); var resultsDatastore = new ResultsDatastore(); - + app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded // Create a new run app.post('/api/runs', function(req, res) { @@ -330,4 +330,4 @@ var ApiController = function(app) { }; -module.exports = ApiController; \ No newline at end of file +module.exports = ApiController; From 990237f97569b705bf306c875b66b0ecd0e20198 Mon Sep 17 00:00:00 2001 From: Vincent L Date: Wed, 18 May 2016 22:54:56 +0200 Subject: [PATCH 2/3] Update apiController.js --- lib/server/controllers/apiController.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/server/controllers/apiController.js b/lib/server/controllers/apiController.js index 49ab41b..765f490 100644 --- a/lib/server/controllers/apiController.js +++ b/lib/server/controllers/apiController.js @@ -7,7 +7,6 @@ var RunsQueue = require('../datastores/runsQueue'); var RunsDatastore = require('../datastores/runsDatastore'); var ResultsDatastore = require('../datastores/resultsDatastore'); var serverSettings = require('../../../server_config/settings.json'); -var bodyParser = require('body-parser'); var ApiController = function(app) { 'use strict'; @@ -16,8 +15,6 @@ var ApiController = function(app) { var runsDatastore = new RunsDatastore(); var resultsDatastore = new ResultsDatastore(); - app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded - // Create a new run app.post('/api/runs', function(req, res) { From 5e4d3c40f5b2f8d0d0c644596332aadb04160aac Mon Sep 17 00:00:00 2001 From: Vincent L Date: Wed, 18 May 2016 23:01:01 +0200 Subject: [PATCH 3/3] Fix pull request #158 https://github.com/gmetais/YellowLabTools/pull/158#issuecomment-220123344 --- bin/server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/server.js b/bin/server.js index 9ad04a8..394af07 100644 --- a/bin/server.js +++ b/bin/server.js @@ -17,6 +17,7 @@ app.use(cors()); app.use(wwwRedirectMiddleware); app.use(authMiddleware); app.use(apiLimitsMiddleware); +app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded // Initialize the controllers @@ -37,4 +38,4 @@ if (!process.env.GRUNTED) { }); } -module.exports = app; \ No newline at end of file +module.exports = app;