-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (31 loc) · 851 Bytes
/
app.js
File metadata and controls
40 lines (31 loc) · 851 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 ErrorHandler = require("./middleware/error");
const app = express();
const cookieParser = require("cookie-parser");
const bodyParser = require("body-parser");
const cors = require("cors");
let origin;
if (process.env.NODE_ENV !== "PRODUCTION") {
origin = "http://localhost:3000";
} else {
origin = "https://www.ckodon.com/";
}
app.use(
cors({
origin: "*",
credentials: true,
})
);
app.use(express.json({ limit: "50mb" }));
app.use(cookieParser());
app.use("/", express.static("uploads"));
app.use(bodyParser.urlencoded({ extended: true, limit: "50mb" }));
if (process.env.NODE_ENV !== "PRODUCTION") {
require("dotenv").config({
path: "./.env",
});
}
const Story = require("./controllers/story");
app.use("/api/v1/stories", Story);
app.use(ErrorHandler);
module.exports = app;