-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
27 lines (23 loc) · 776 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
import mongoose from 'mongoose';
import express from 'express';
import authRoutes from './routes/auth-routes.js';
import bodyParser from 'body-parser';
import logger from './logger.js';
import statusRoutes from './routes/status-routes.js';
import cors from 'cors';
import profileRoutes from './routes/profile-routes.js';
const app = express();
const port = 7777;
app.use(bodyParser.json({}));
app.use(cors());
app.use('/api/health', statusRoutes);
app.use('/api/auth', authRoutes);
app.use('/api/profile', profileRoutes);
mongoose
.connect(`${process.env.MONGODB_CONNECTION}`)
.then(() => {
app.listen(port, () => logger.info(`Server listening on port ${port}`));
})
.catch((error) => {
logger.error(`Could not connect to DB\n${error}`, { at: new Error() });
});