Skip to content
This repository has been archived by the owner on Oct 5, 2020. It is now read-only.

Commit

Permalink
Fixed #31: moved bodyparsing to allow upload of non-json
Browse files Browse the repository at this point in the history
  • Loading branch information
grtjn committed Mar 1, 2016
1 parent c96460a commit 90c8775
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 1 addition & 5 deletions app/templates/node-server/node-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var express = require('express');
var expressSession = require('express-session');
var app = express();
var bodyParser = require('body-parser');
var logger = require('morgan');
var port = process.env.PORT || 8001;
var four0four = require('./utils/404')();
Expand All @@ -18,13 +17,10 @@ app.use(expressSession({
resave: true
}));

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(logger('dev'));

app.use('/api', require('./routes'));

app.use('/v1', require('./proxy'));
app.use('/api', require('./routes'));

app.use('/create', express.static('./build/index.html'));
app.use('/profile', express.static('./build/index.html'));
Expand Down
5 changes: 5 additions & 0 deletions app/templates/node-server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'use strict';

var router = require('express').Router();
var bodyParser = require('body-parser');
var four0four = require('./utils/404')();
var http = require('http');
var config = require('../gulp.config')();
Expand All @@ -15,6 +16,10 @@ var options = {
defaultPass: process.env.ML_APP_PASS || config.marklogic.password
};

// [GJo] (#31) Moved bodyParsing inside routing, otherwise it might try to parse uploaded binaries as json..
router.use(bodyParser.urlencoded({extended: true}));
router.use(bodyParser.json());

router.get('/user/status', function(req, res) {
var headers = req.headers;
noCache(res);
Expand Down

0 comments on commit 90c8775

Please sign in to comment.