-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (37 loc) · 788 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"use strict";
const express = require("express");
const app = express();
const cors = require("cors");
const dotenv = require('dotenv');
dotenv.config();
app.use(
express.json({
limit: "10mb",
})
);
app.use(
express.urlencoded({
limit: "10mb",
extended: true,
})
);
// DB Connection
require("./database/connection");
app.use(
cors({
origin: ["http://localhost:3000"],
methods: "GET,POST,PATCH,DELETE",
credentials: true,
})
);
app.use(require("./routes"));
if(process.env.NODE_ENV !== "test") {
var server = app.listen(process.env.PORT, () => {
console.log("Listing at port ", process.env.PORT);
});
} else { // for unit testing
var server = app.listen(0, () => {
console.log("Listing at port 0");
});
}
module.exports = server;