From d7052b691c0437ba0104a7d6d0105856ee661d65 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Tue, 23 May 2017 13:26:26 +0200 Subject: [PATCH] Fix production logging --- api/config/config.js | 4 ++++ api/package.json | 2 +- api/server.js | 2 +- package.json | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/config/config.js b/api/config/config.js index 549212b..b1d5ca0 100644 --- a/api/config/config.js +++ b/api/config/config.js @@ -7,6 +7,10 @@ module.exports = { db: 'cc', }, + dev: { + env: 'dev' + }, + test: { port: 3001, db: 'cc-test', diff --git a/api/package.json b/api/package.json index f86c04f..5249ecb 100644 --- a/api/package.json +++ b/api/package.json @@ -8,7 +8,7 @@ "private": true, "scripts": { "start": "NODE_ENV=production node server.js", - "dev": "nodemon server.js", + "dev": "NODE_ENV=dev nodemon server.js", "test": "mocha --require ./test/config/spec_helper.js", "e2e": "NODE_ENV=test node server.js" }, diff --git a/api/server.js b/api/server.js index d0216d5..9cab504 100644 --- a/api/server.js +++ b/api/server.js @@ -55,7 +55,7 @@ app.use(restAPIchecks); app.use(urls.signatures, signatureRouter); // initialize logging here to exclude /signature requests -if (!process.env.NODE_ENV) { +if (process.env.NODE_ENV === config.dev.env) { // development logging app.use(requestLogger('dev')); } else if (process.env.NODE_ENV !== config.test.env) { diff --git a/package.json b/package.json index e178efb..3eada58 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "license": "MIT", "private": true, "scripts": { - "start": "npm run deploy-static-prod && NODE_ENV=production node ./api/server.js", - "dev": "npm run deploy-static && nodemon ./api/server.js", + "start": "npm run deploy-static-prod && npm start --prefix ./api", + "dev": "npm run deploy-static && npm run dev --prefix ./api", "deploy-static": "cd ./static && ng build && ln -s ../api/resource/ ../public/resource", "deploy-static-prod": "cd ./static && ng build --env=prod && ln -s ../api/resource/ ../public/resource", "postinstall": "npm install --prefix ./static && npm install --prefix ./api",