forked from CougarCS/CougarCS-Cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
30 lines (23 loc) · 813 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
const express = require('express');
const cors = require('cors');
// const compression = require('compression');
const app = express()
app.use(express.json())
app.use(cors());
// app.use(compression());
app.use(express.urlencoded({ extended: false }));
var indexRouter = require('./routes/index');
var loginRouter = require('./routes/login');
var contactRouter = require('./routes/contact');
var contactsRouter = require('./routes/contacts');
app.use('/', indexRouter);
app.use('/login', loginRouter);
app.use('/contact', contactRouter);
app.use('/contacts', contactsRouter);
// Default to 404 if Endpoint/Method Not Recognized
app.use((req, res, next) => {
res.status(404);
if (req.accepts('json')) res.json({ error: 'Not found' });
else res.type('txt').send('Not found');
});
module.exports = app;