-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
26 lines (22 loc) · 873 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
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require("body-parser");
const swaggerUi = require("swagger-ui-express");
const specs = require("./src/helpers/swaggerOptions");
const app = express();
const cors = require('cors');
require('dotenv').config();
app.use(express.json());
app.use(cors());
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('MongoDB Connected...'))
.catch(err => console.log(err));
// Routes
app.use("/lists", require('./src/routes/lists'));
app.use("/user", require('./src/routes/user'));
app.use(require('./src/routes/auth'));
app.use("/docs", swaggerUi.serve, swaggerUi.setup(specs, { explorer: true }));
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Server is up on port ${port}`);
});