This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
66 lines (54 loc) · 2.25 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
//PaRaMeRoS Backend
//Copyright (C) 2024 David Frings
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as published
//by the Free Software Foundation, either version 3 of the License, or
//any later version.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//Affero General Public License for more details.
//You should have received a copy of the GNU Affero General Public License
//along with this program. If not, see <https://www.gnu.org/licenses/>.
//You can contact me by writing a mail to [email protected]
require("dotenv").config();
const env = process.env;
const express = require("express");
const app = express();
const router = express.Router();
const moment = require("moment");
const cors = require("cors");
const path = require("path");
const connection = require("./db");
const { red } = require("./utilities");
const { green } = require("./utilities");
const { yellow } = require("./utilities");
const authRoute = require("./routes/auth");
const eventRoute = require("./routes/events");
const hobbiesRoute = require("./routes/hobbies");
const teamRoute = require("./routes/team");
const terminalRoute = require("./routes/terminal");
const uploadRoute = require("./routes/upload");
//Time
moment.defaultFormat = "[[]DD[/]MM[/]YYYY HH[:]mm[:]ss[]]";
//Database
connection();
//Middlewares
app.use(express.static("public"));
app.use(express.json());
app.use(cors());
//Routes
app.use("/api/users", router);
app.use("/api/auth", authRoute);
app.use("/api/events", eventRoute);
app.use("/api/hobbies", hobbiesRoute);
app.use("/api/team", teamRoute);
app.use("/api/upload", uploadRoute);
app.use("/api/terminal", terminalRoute);
app.use("/api/images", express.static(path.join(__dirname, "./images")));
//Redirect
app.get("/*", (req, res) => {
res.redirect(env.FRONTEND);
});
//Start
app.listen(env.PORT, () => console.log(yellow, moment().format() + "Listening on port " + env.PORT));