forked from EmmaFrith/exhibition-calendar-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (27 loc) · 923 Bytes
/
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
import 'dotenv/config';
// import path, { dirname } from 'path';
import { connectToDb } from './db/helpers.js';
import express from 'express';
// import { fileURLToPath } from 'url';
import { port } from './config/environment.js';
import exhibitionRouter from './controllers/exhibition.js';
import authRouter from './controllers/auth.js';
import userRouter from './controllers/user.js';
const app = express();
app.use(express.json());
app.use('/api', exhibitionRouter)
app.use('/api/auth', authRouter)
app.use('/api/user', userRouter)
// const __filename = fileURLToPath(import.meta.url);
// const __dirname = dirname(__filename);
async function startServer() {
try {
await connectToDb();
console.log('Database connected');
app.listen(port, () => console.log(`Listening on Port: ${port}`));
} catch (err) {
console.log('Oh no something went wrong');
console.log(err);
}
}
startServer();