-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
29 lines (26 loc) · 903 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
const express = require('express');
const morgan = require('morgan');
const userRoute = require('./routes/userRoutes');
const driverRoute = require('./routes/driverRoutes');
const chatRoute = require('./routes/chatRoutes');
const AppError = require('./utils/appError');
const glopalErrorHandler = require('./controllers/errorController');
const { default: mongoose } = require('mongoose');
const app = express();
app.use(morgan('dev'));
app.use(express.json());
const cookieParser = require('cookie-parser');
// Use cookie-parser middleware
app.use(cookieParser());
// app.use('/', (req, res) => {
// res.send('Hello World !');
// });
// ROUTES
app.use('/user', userRoute);
app.use('/driver', driverRoute);
app.use('/chat', chatRoute);
app.all('*', (req, res, next) => {
next(new AppError(`Can't find ${req.originalUrl} on this server !`));
});
app.use(glopalErrorHandler);
module.exports = app;