forked from fybx/zkl-ccir
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
51 lines (44 loc) · 1.42 KB
/
index.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
47
48
49
50
51
const express = require("express");
const mongoose = require("mongoose");
const cors = require("cors");
const morgan = require("morgan");
const appRoute = require("./routes/app.route.js");
require("dotenv").config();
const PORT = process.env.PORT || 3000;
const logger = (req, res, next) => {
console.log(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
);
console.log("----------BODY----------");
console.log(req.body);
console.log();
console.log("----------HEAD----------");
console.log(req.headers);
console.log(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
);
next();
};
const app = express();
app.enable("trust proxy");
app.disable("x-powered-by");
app.use(express.json({ limit: "64mb" }));
app.use(cors());
app.use(
morgan(
"[ :method :url ] ~:status | :date[web] | :total-time[digits] ms | IP :remote-addr | :user-agent",
),
);
app.use(logger, appRoute);
mongoose.connect(process.env.MONGODB_URI).then(() => {
console.info("Database connected");
});
app.get("/api/hello", (req, res) => {
res.status(200).json({
message: "Close the world, .txen eht nepO",
author: "Yigid BALABAN <[email protected]>",
authorHomepage: "https://fybx.dev/",
thanks: "to Abdullah VELISOY, login.xyz, my family",
});
});
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));