-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (34 loc) · 982 Bytes
/
server.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
38
39
/**
* @file server.js
* @class Base server file
* @classdesc Interface to comunicate with the API.
* @since v1.0.0
* @author boykland/clenondavis <[email protected]>
*/
//#region lib
import express from "express";
import bodyParser from "body-parser";
import endpoints from "./endpoint";
import cors from "cors";
import mongoose from "mongoose";
//#endregion
const app = express();
const port = process.env.PORT || 7000;
// app.use(morgan('combined'));
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(endpoints);
const db = mongoose.connection;
mongoose.connect("mongodb://localhost:27017", {
dbName: "covidjsni",
useNewUrlParser: true,
useUnifiedTopology: true,
});
db.on("error", console.error.bind(console, "connection error:"));
db.once("open", function () {
console.log("|o| DATABASE connected");
app.listen(port, () =>
console.log(`|o| SERVER is now listening on port ${port}`)
);
});