-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (51 loc) · 1.99 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
52
53
54
55
/*
--------------------------------------------------------------------
IMPORTS
--------------------------------------------------------------------
*/
import express from "express"
import path from 'path'
import Db from "./src/models/db.mjs";
import {dirname} from "node:path";
import {fileURLToPath} from "node:url";
import {router} from "./src/routes/indexRoutes.js"
import {printServerStart} from "./src/util/consoleUtil.js";
const app = express();
// ----------------------------------------------------------------------------
const PORT = 3000;
// ----------------------------------------------------------------------------
/*
--------------------------------------------------------------------
MIDDLEWARES
--------------------------------------------------------------------
*/
app.set("views", "./views");
app.set('view engine', "pug")
/*
--------------------------------------------------------------------
MODELS
--------------------------------------------------------------------
*/
export const db = new Db()
db.init().then()
/*
--------------------------------------------------------------------
STATICS
--------------------------------------------------------------------
*/
app.use('/css', express.static(path.join(dirname(fileURLToPath(import.meta.url)), 'node_modules/bootstrap/dist/css')))
app.use('/js', express.static(path.join(dirname(fileURLToPath(import.meta.url)), 'node_modules/bootstrap/dist/js')))
app.use('/js', express.static(path.join(dirname(fileURLToPath(import.meta.url)), 'node_modules/jquery/dist')))
app.use(express.static(path.join(dirname(fileURLToPath(import.meta.url)), 'public')))
/*
--------------------------------------------------------------------
ROUTERS
--------------------------------------------------------------------
*/
app.use(router);
/*
--------------------------------------------------------------------
START THE SERVER
--------------------------------------------------------------------
*/
app.listen(PORT, () => printServerStart(PORT));