Skip to content

Commit

Permalink
fix: body parser before commons middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
cesgarpas committed Jul 6, 2021
1 parent 45812dd commit f1238c4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Check syntax
run: npm run lint
env:
# TODO
# - name: Check syntax
# run: npm run lint
# env:
# CI: true
# - name: Run tests
# run: npm run test
Expand Down
33 changes: 15 additions & 18 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */

'use strict';




function check (name, pass, config) {
const nameOK = config.auth.user;
const passOK = config.auth.password;
Expand All @@ -45,9 +42,23 @@ const deploy = (env, commonsMiddleware, callback) => {
const governify = require('governify-commons');
const logger = governify.getLogger().tag('initialization');
const config = require('./src/backend/configurations');


const app = express();

app.use(
bodyParser.urlencoded({
limit: '50mb',
extended: 'true'
})
);

app.use(
bodyParser.json({
limit: '50mb',
type: 'application/json'
})
);

app.use(commonsMiddleware);

if (config.server.enableHTTPBasicAuth) {
Expand All @@ -68,20 +79,6 @@ const deploy = (env, commonsMiddleware, callback) => {

app.use(compression());

app.use(
bodyParser.urlencoded({
limit: '50mb',
extended: 'true'
})
);

app.use(
bodyParser.json({
limit: '50mb',
type: 'application/json'
})
);

const frontendPath = path.join(__dirname, '/src/frontend');
logger.info("Serving '%s' as static folder", frontendPath);
app.use(express.static(frontendPath));
Expand Down
2 changes: 1 addition & 1 deletion src/backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mustache.escape = function (text) { return text; };
const governify = require('governify-commons');

const config = require('./configurations');
const logger = governify.getLogger().tag("routes")
const logger = governify.getLogger().tag('routes');

module.exports = router;

Expand Down

0 comments on commit f1238c4

Please sign in to comment.