-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
38 lines (30 loc) · 1.21 KB
/
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
33
34
35
36
37
38
// require framework and middleware dependencies
const express = require('express');
const path = require('path');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const { authenticate } = require('./middlewares/authentication.middleware');
// const multer = require('multer');
require('dotenv').config();
const app = express();
app.use(logger('dev'));
app.use(express.urlencoded({ extended: false })); // parse application/x-www.js-form-urlencoded
app.use(express.json({ limit: '4MB' })); // parse application/json
app.use(cookieParser());
// app.use(multer().none());
app.use(
express.static(path.join(__dirname, 'public'), { index: 'index.html' })
);
app.use('/media', express.static(path.join(__dirname, 'media')));
app.set('view engine', 'html');
// TODO - controllers
app.use('/auth', require('./routes/auth'));
app.use('/api', authenticate, require('./routes/chat'));
app.use('/api', authenticate, require('./routes/group'));
app.use('/upload', authenticate, require('./routes/upload'));
// serve Vue app if no matching route is found
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'public/index.html'));
});
app.locals.onlineUsers = new Set();
module.exports = app;