Skip to content

Commit

Permalink
Fixed marklogic-community#31: moved bodyparsing to allow upload of no…
Browse files Browse the repository at this point in the history
…n-json
  • Loading branch information
grtjn committed Feb 23, 2016
1 parent 2c437b5 commit 88791e4
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 cookieParser = require('cookie-parser');
var logger = require('morgan');
var port = process.env.PORT || 8001;
Expand All @@ -20,13 +19,10 @@ app.use(expressSession({
}));

app.use(cookieParser());
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 88791e4

Please sign in to comment.