-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (33 loc) · 868 Bytes
/
server.js
File metadata and controls
40 lines (33 loc) · 868 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
29
30
31
32
33
34
35
36
37
38
39
40
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const swaggerJsdoc = require("swagger-jsdoc");
const swaggerUi = require("swagger-ui-express");
require('dotenv/config')
const app = express();
const port = process.env.PORT || 8000;
/// MIDDLEWARE ///
// Swagger documentation
const specs = swaggerJsdoc(require("./config/swagger_config"));
app.use(
"/api-docs",
swaggerUi.serve,
swaggerUi.setup(specs)
);
app.use(bodyParser.json());
app.use('/api/person', require('./routes/person'))
// Connect to MongoDB
mongoose.connect(
process.env.DB_CONNECTION,
{
useNewUrlParser: true,
useUnifiedTopology: true,
},
(err) => {
if (err) console.log(err)
else console.log("connected to DB!")
},
);
app.listen(port, () => {
console.log('We are live on port: ' + port);
});