Skip to content

Commit

Permalink
Add morgan logger
Browse files Browse the repository at this point in the history
  • Loading branch information
nedssoft committed Jan 22, 2020
1 parent 35cb8ff commit 1ff5230
Show file tree
Hide file tree
Showing 6 changed files with 2,520 additions and 531 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
.env
/coverage
/coverage

8 changes: 8 additions & 0 deletions api/server.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import express from 'express';
import { bouncer } from 'express-error-bouncer';
import cors from 'cors';
import path from 'path';
import morgan from 'morgan';
import fs from 'fs';
import routes from '../routes';


const app = express();

const accessLogStream = fs.createWriteStream(path.join(__dirname, '../logs/access.log'));

app.use(express.json());
app.use(morgan('combined', { stream: accessLogStream }));

app.use(cors());
app.use('/api', routes);
app.use(bouncer);
Expand Down
1 change: 1 addition & 0 deletions logs/access.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::ffff:127.0.0.1 - - [22/Jan/2020:10:26:34 +0000] "GET /api HTTP/1.1" 200 9 "-" "node-superagent/3.8.3"
Loading

0 comments on commit 1ff5230

Please sign in to comment.