38 lines
782 B
JavaScript
38 lines
782 B
JavaScript
import { dbInit } from './libs/database.js'
|
|
import dotenv from 'dotenv'
|
|
import express from 'express'
|
|
import njk from 'nunjucks'
|
|
import ROUTES from './routes/routes.js'
|
|
|
|
dotenv.config()
|
|
|
|
const APP = express()
|
|
const PORT = process.env.PORT ?? 12345
|
|
|
|
await dbInit()
|
|
.then(
|
|
() => console.log("Connected to database!")
|
|
).catch(
|
|
err => console.log("Error occured!") && console.dir(err, { depth: null })
|
|
)
|
|
|
|
APP.use(express.urlencoded({ extended: true }))
|
|
APP.use('/static', express.static('static'))
|
|
|
|
APP.use('/', ROUTES)
|
|
|
|
njk.configure(
|
|
'views',
|
|
{
|
|
autoescape: true,
|
|
lstripBlocks: true,
|
|
trimBlocks: true,
|
|
express: APP,
|
|
}
|
|
)
|
|
|
|
APP.listen(
|
|
PORT,
|
|
() => console.log('Server started at http://localhost:' + PORT)
|
|
)
|