Skip to content

Commit

Permalink
fix(app): fix double morgan log entry
Browse files Browse the repository at this point in the history
add config for choose custom format
  • Loading branch information
navarroaxel committed Oct 7, 2018
1 parent f153d87 commit 351051f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module.exports = {
| | `MONGODB_URI` | Connection string to the MongoDB server | `mongodb://localhost:27017` |
| | `RECEIVE_ONLY` | True if Sivy works on receive_only mode | `false` |
| :bangbang: | `AUTH_CLIENT_SECRET` | The secret to validate the JWT. | |
| | `MORGAN_FORMAT` | Log format used by Morgan package | `combined` for production, else `dev` |
| | `DEBUG` | Set to `sivy` to turn on debug logging. | |

### Authentication
Expand Down
1 change: 0 additions & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class Config {
app.use(require('body-parser').urlencoded({extended: true}));

app.use(require('cookie-parser')());
app.use(require('morgan')('dev'));

require('node-friendly-response');

Expand Down
3 changes: 2 additions & 1 deletion config/development.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const {MORGAN_FORMAT} = process.env;
const Config = require('./config');

class Development extends Config {
static configure(app) {
super.configure(app);
app.use(require('morgan')('dev'));
app.use(require('morgan')(MORGAN_FORMAT || 'dev'));

app.use(require('cors')({
credentials: true,
Expand Down
3 changes: 2 additions & 1 deletion config/production.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const {MORGAN_FORMAT} = process.env;
const Config = require('./config');

class Production extends Config {
static configure(app) {
super.configure(app);
app.use(require('morgan')('combined'));
app.use(require('morgan')(MORGAN_FORMAT || 'combined'));
app.use(require('cors')());
}
}
Expand Down
3 changes: 2 additions & 1 deletion config/staging.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const {MORGAN_FORMAT} = process.env;
const Config = require('./config');

class Staging extends Config {
static configure(app) {
super.configure(app);
app.use(require('morgan')('combined'));
app.use(require('morgan')(MORGAN_FORMAT || 'combined'));
app.use(require('cors')());
}
}
Expand Down

0 comments on commit 351051f

Please sign in to comment.