-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (25 loc) · 807 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
import router from './routers/activity.router.js';
import mongoose from 'mongoose';
import express from 'express';
import dotenv from 'dotenv';
import cors from 'cors';
dotenv.config();
const config = {
compass : process.env.MONGODB_COMPASS,
atlas : process.env.MONGODB_ATLAS,
dbase : process.env.DB_NAME,
port : process.env.PORT
};
mongoose.set('strictQuery', true)
mongoose.connect(`${config.atlas || config.compass}`, {
useUnifiedTopology: true,
useNewUrlParser: true,
});
const dbase = mongoose.connection;
dbase.once('open', () => console.info('mongoose connected!!'));
dbase.on('error', error => console.error(error));
const app = express();
app.listen(config.port || 5000, () => console.info('server running at port 5000'));
app.use(express.json());
app.use(cors());
app.use(router);