-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (30 loc) · 790 Bytes
/
index.js
File metadata and controls
37 lines (30 loc) · 790 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
require("dotenv").config();
const express = require("express");
const logger = require("morgan");
const helmet = require("helmet");
const cors = require("cors");
const config = require("./src/config");
const connect = require("./src/utils/db");
const { json, urlencoded } = require("body-parser");
const server = {};
const app = express();
app.disable("x-powered-by");
app.use(cors());
app.use(json());
app.use(urlencoded({ extended: true }));
app.use(logger("dev"));
server.init = async function() {
try {
await connect();
app.listen(config.port, () => {
console.log(
"\x1b[35m%s\x1b[0m",
`Magic happening on http://localhost:${config.port}`
);
});
} catch (error) {
console.log(error);
}
};
server.init();
module.exports = server;