-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserver.js
46 lines (40 loc) · 1.22 KB
/
server.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
45
46
const express = require("express");
const mongoose = require("mongoose");
const cors = require("cors");
const event = require("./routes/event");
const user = require("./routes/user");
//const verify = require("./routes/verify");
const ip = require("ip");
require("dotenv").config();
require("dotenv/config");
const bodyParser = require("body-parser");
const app = express();
const port = 8080;
mongoose.connect(process.env.DB_URL, { useNewUrlParser: true }, () => {
console.log("Connected to MongoDB");
});
app.use(express.static("./images"));
app.use(bodyParser.json({ limit: "50mb" }));
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
app.use(cors());
app.use("/event", event);
app.use("/user", user);
app.get("/", (req, res) => {
console.log(req.url);
console.log(req.headers);
console.log(req.body);
console.log(req.ip);
res.send(req.headers, req.data, req.ip, req.router, req.body);
});
app.get("/nukes", (req, res) => {
try {
res.json({ isNukesActive: true });
} catch (err) {
console.log(err);
res.json({ code: err.code, message: err.message });
}
});
app.listen(process.env.PORT || port, () => {
console.log(`Server running at http://${ip.address()}:${port}`);
});
module.exports = app;