-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (24 loc) · 1.01 KB
/
app.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
//CONFIGURES express server
// ℹ️ Gets access to environment variables/settings
require("dotenv").config();
// ℹ️ Connects to the database
require("./db/index");
// import the models so the connect to the database
require("./models/User.model");
require("./models/PlayAnalytics.model");
require("./models/Rating.model");
require("./models/Leaderboard.model");
require("./models/Game.model");
// Handles http requests (express is node js framework)
const express = require("express");
const app = express();
// ℹ️ This function is getting exported from the config folder. It runs most pieces of middleware
require("./config")(app);
// 👇 Start handling routes here (this are the important routes)
const indexRoutes = require("./routes/index.routes");
app.use("/api", indexRoutes);
const authRoutes = require("./routes/auth.routes");
app.use("/auth", authRoutes);
// ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes
require("./error-handling")(app);
module.exports = app;