-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
67 lines (53 loc) · 1.59 KB
/
index.js
File metadata and controls
67 lines (53 loc) · 1.59 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require('dotenv').config({
path: './config_files/.env'
})
const express = require("express");
const app = express();
const cors = require("cors");
app.use(express.json());
app.use(cors());
const path = require("path")
const mainURL = "http://localhost:4000/";
let database = null;
let http = require("http").createServer(app);
app.use(express.json());
const expressSession = require("cookie-session");
app.use(
expressSession({
key: "user_id",
secret: "User secret object ID",
resave: true,
saveUninitialized: true,
})
);
const bodyParser = require("body-parser");
app.use(bodyParser.json({ limit: "10000mb" }));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(
bodyParser.urlencoded({
extended: true,
limit: "10000mb",
parameterLimit: 1000000,
})
);
app.use("/", require("./routes/image"));
app.use('/api', require("./routes/route"));
// --------------------------deployment------------------------------
// const __dirname = path.resolve();
if (process.env.NODE_ENV === "production" || process.env.NODE_ENV === "staging") {
app.use(express.static(path.join(__dirname, 'client/build')));
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
} else {
app.get("/", (req, res) => {
res.send("API is running..");
});
}
// --------------------------deployment------------------------------
const PORT = process.env.PORT || 4000;
http.listen(PORT, function () {
console.log("Server has started...");
});
// 16e007779c2b2f33fa8dea43246ac9ca-us9
// 0758ba2e33