-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (32 loc) · 954 Bytes
/
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
require("dotenv").config({ path: "./src/env/.env" });
const express = require("express");
const cors = require("cors");
const path = require("path");
const bodyParser = require("body-parser");
const session = require("express-session");
const { app } = require("./src/helpers/timer");
app.use(bodyParser.raw());
// session
app.use(
session({
secret: "happyHunt",
resave: true,
saveUninitialized: true,
})
);
// routes
const authRouter = require("./src/api/auth");
const apiRouter = require("./src/api/api");
// connections
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(cors());
app.use("/auth", authRouter);
app.use("/api", apiRouter);
global.appRoot = path.resolve(__dirname);
const port = 3000;
app.use(express.static("frontend/build"));
app.use((req, res) => {
res.sendFile(`${__dirname}/frontend/build/index.html`);
});
app.listen(port, () => console.log(`server started at port ${port}`));