-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
39 lines (33 loc) · 1.18 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
39
require('dotenv').config();
const express = require('express');
const helmet = require('helmet');
const notFound = require('./middlewares/not-found');
const errorHandlerMiddleware = require('./middlewares/error-handler');
const userRoutes = require('./routes/users');
const orgRoutes = require('./routes/orgRoutes');
const lunchRoutes = require('./routes/lunchRoutes');
const authRoutes = require('./routes/auth.route');
const withDrawalRoute = require('./routes/withdraw.route');
const sequelize = require('./db/db');
const app = express();
// Configurations
app.use(express.json());
app.use(helmet());
const PORT = process.env.PORT || 4000;
app.use('/api/users', userRoutes);
app.use('/api/auth', authRoutes);
app.use('/api/organization', orgRoutes);
app.use('/api/lunch', lunchRoutes);
app.use('/api/withdrawal', withDrawalRoute);
app.use('/public/docs', express.static('./public/docs'));
// Middlewares
app.use(errorHandlerMiddleware);
app.use(notFound);
sequelize.sync().then(() => {
// Remove console.log() before production
console.log('Database & tables created!');
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
});
module.exports = app; //for testing