-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (26 loc) · 807 Bytes
/
index.js
File metadata and controls
28 lines (26 loc) · 807 Bytes
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
import express from 'express';
import bodyParser from 'body-parser';
import dotenv from 'dotenv';
import morgan from 'morgan';
import authRoutes from './routes/auth.js';
import userRoutes from './routes/user.js';
import eventRoutes from './routes/event.js';
import cors from 'cors'
import connectDB from './config/db.js';
dotenv.config()
const app=express();
app.use(express.json())
app.use(bodyParser.json({ limit: "50mb", extended: true }));
app.use(cors());
app.use(morgan("common"))
const PORT = process.env.PORT;
app.use('/api/auth',authRoutes);
app.use('/api/user',userRoutes);
app.use('/api/events',eventRoutes);
connectDB().then(()=>{
app.listen(PORT,"0.0.0.0",()=>{
console.log(`Server running on: ${PORT}`);
})
}).catch((error)=>{
console.log(`${error} did not connect`)
})