-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
43 lines (38 loc) · 1.09 KB
/
app.js
File metadata and controls
43 lines (38 loc) · 1.09 KB
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
if (process.env.NODE_ENV !== "production") {
require("dotenv").config();
}
const express = require("express");
const bodyParser = require("body-parser");
const helmet = require("helmet");
const cors = require("cors");
const healthcheck = require("./routes/api");
const coupon = require("./routes/coupon");
const user = require("./routes/user");
const app = express();
const http = require("http");
const server = http.createServer(app);
app.use(bodyParser.json({ type: "application/vnd.api+json" }));
app.use(helmet());
app.use(
cors({
allowedHeaders: [
"Content-Type",
"token",
"authorization",
"*",
"Content-Length",
"X-Requested-With",
],
origin: "*",
preflightContinue: true,
})
);
app.use(express.json({ limit: "1024mb" }));
app.use(express.urlencoded({ limit: "1024mb", extended: true }));
const PORT = process.env.PORT || 5000;
app.use("/api", healthcheck);
app.use("/api/coupon", coupon);
app.use("/api/user", user);
server.listen(PORT, () => {
console.log(`Server started on port ${PORT}`);
});