-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (28 loc) · 1.02 KB
/
server.js
File metadata and controls
33 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import path from 'path';
import express from 'express';
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import config from './webpack.config';
import cookieParser from 'cookie-parser';
import bodyParser from 'body-parser';
import getAll from './routers/getAll';
import movieDb from './routers/movieDb';
import mlabDb from './routers/mlabDb';
const app = express();
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }));
app.use(webpackHotMiddleware(compiler));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(express.static(__dirname + '/static'));
app.use(logger)
app.use('/api/moviedb', movieDb);
app.use('/api/mlabdb', mlabDb);
app.get('/*', getAll);
function logger(req, res, next) {
console.log(`--start--\n Method: ${req.method}
Url: ${req.originalUrl}\n Body: ${JSON.stringify(req.body)}\n--end--\n`);
next();
}
export default app;