forked from eledx/slack-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (24 loc) · 842 Bytes
/
app.js
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
const express = require('express');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const path = require('path');
const cookieParser = require('cookie-parser');
const routes = require('./routes');
const { setUser } = require('./middlewares');
const app = express();
// Middlewares
app.use(morgan('dev'));
// Body Parser configuration
app.use(cookieParser());
app.use(bodyParser.json({ limit: '10mb', extended: true }));
app.use(bodyParser.urlencoded({ limit: '10mb', extended: true }));
app.use(setUser);
app.use('/api', routes);
// Authentification
app.use('/auth', routes);
// pour heroku + commande ds package
app.use(express.static(path.join(__dirname, 'webapp', 'build')));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'webapp', 'build', 'index.html'));
});
module.exports = app;