-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
34 lines (27 loc) · 952 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
33
34
import 'dotenv/config';
import express from 'express';
import logger from 'morgan';
import bodyParser from 'body-parser';
import cors from 'cors';
import AuthRoutes from './Server/routes/authRoutes';
import UserRoutes from './Server/routes/userRoutes';
import AdminRoutes from './Server/routes/adminRoutes';
const app = express();
const port = process.env.PORT || 3010;
app.use(cors());
app.use(logger('dev'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use('/api/v1/auth', AuthRoutes);
app.use('/api/v1/users', UserRoutes);
app.use('/api/v1/requests', AdminRoutes);
app.get('/api/v1/docs', (req, res) => res.redirect('https://maintenancetracker1.docs.apiary.io/#'));
app.use('/', express.static('public'));
app.all('*', (req, res) => res.status(404).json({
status: 'error',
code: 404,
message: 'Route unavailable on server.',
}));
app.listen(port);
export const server = app;
export default app;