-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
33 lines (30 loc) · 1.05 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
const express = require('express');
const app = express();
const cors = require('cors');
const morgan = require('morgan');
const port = process.env.PORT || 5000;
const bootcamperRouter = require('./routes/bootcampers');
const reflectionRouter = require('./routes/reflections');
const topicsRouter = require('./routes/topics');
const dashboardRouter = require('./routes/dashboard');
const quoteRouter = require('./routes/quotes');
const authRouter = require('./routes/auth');
// Middlewares
app.use(cors({ origin: '*' }));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(morgan(':method :url :status :response-time ms - :res[content-length]'));
//Routers
app.use('/bootcampers', bootcamperRouter);
app.use('/reflections', reflectionRouter);
app.use('/topics', topicsRouter);
app.use('/dashboard', dashboardRouter);
app.use('/quote', quoteRouter);
app.use('/auth', authRouter);
app.get('/', (req, res) => {
res.json({
success: true,
payload: 'it worked',
});
});
app.listen(port, () => console.log('listening on port ' + port));