-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
74 lines (60 loc) · 1.6 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require("dotenv").config();
// Declare Middleware
global.fetch = require("node-fetch");
const express = require("express");
const cors = require("cors");
const jwt = require("jsonwebtoken");
const fs = require("fs");
const helmet = require("helmet");
const app = express();
const http = require("http");
const server = http.createServer(app);
const bodyParser = require("body-parser");
// Declare Connection
const connectionDatabase = require("./app/config/db.connection");
const connectionFirebase = require("./app/config/firebase.connection");
//Socket
const { io } = require("./app/config/socket.config");
// Middleware
app.use(cors());
app.use(helmet.hsts());
// app.use(express.json());
// app.use(bodyParser.json());
app.use(express.json({ limit: "50mb" }));
app.use(express.urlencoded({ extended: true, limit: "50mb" }));
app.use(
bodyParser.json({
limit: "50mb",
})
);
app.use(
bodyParser.urlencoded({
limit: "50mb",
parameterLimit: 100000,
extended: true,
})
);
//Firebase
const fb = require("./app/config/firebase.config");
// uuid
const { uuid } = require("uuidv4");
// Database & Firebase Connection
connectionDatabase();
connectionFirebase();
// Security JWT
require("./app/auth");
// Routes
require("./app/routes/")(app);
// Socket
// require("./app/socket/")(io);
// test API
require("./app/test/routes")(app);
// Welcome page API
app.get("/", (_, res) => {
res.json({ message: "Welcome to MITIVELANE application." });
});
// set port, listen for requests
const PORT = process.env.PORT || 5000;
server.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});