-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (35 loc) · 1.02 KB
/
index.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
40
41
42
43
44
45
import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
import * as dotenv from 'dotenv';
// DB
import connectDB from './db.js';
// Routers
import userRouter from './routes/userRoutes.js';
import planItemRouter from './routes/planItemRoutes.js';
import planRouter from './routes/planRoutes.js';
import activeSubscriptionRouter from './routes/activeSubscriptionRoutes.js';
dotenv.config();
const app = express();
// Global usages
app.use(cors());
app.use(bodyParser.json());
// Routes
app.use('/api/user', userRouter);
app.use('/api/plan-item', planItemRouter);
app.use('/api/plan', planRouter);
app.use('/api/active-subscription', activeSubscriptionRouter);
app.get('/', (req, res) => {
res.send('<h1>Hello from Checkinator\'s powerful server</h1>');
});
const startServer = async () => {
try {
connectDB(process.env.MONGODB_URL);
app.listen(5000, () => {
console.log('Server is running on port 5000');
});
} catch (error) {
console.log(error);
}
};
startServer();