ddstats-server/index.js

34 lines
776 B
JavaScript
Raw Normal View History

2021-10-06 20:36:20 +02:00
/**
* This is the entrypoint for 'DDStats'.
* DDStats is a custom API that servers statistics from the DDRace Network-
* @author BurnyLlama <xmpp:burnyllama@qwik.space>
*/
2021-09-25 12:11:27 +02:00
import express from 'express'
2021-09-25 17:47:05 +02:00
import dotenv from 'dotenv'
2021-10-30 21:39:21 +02:00
import njk from 'nunjucks'
import initLog from './libs/utils/log.js'
2021-10-30 21:39:21 +02:00
import routes from './routes/routes.js'
2021-09-29 20:29:06 +02:00
const log = initLog("[ MAIN ]")
2021-09-25 17:47:05 +02:00
// Read the .env file
dotenv.config()
2021-09-25 12:11:27 +02:00
2021-10-30 21:39:21 +02:00
const Server = express()
njk.configure(
'views',
{
autoescape: true,
express: Server,
lstripBlocks: true,
trimBlocks: true
}
)
Server.use('/', routes)
Server.use('/assets', express.static('static'))
2021-10-16 19:11:16 +02:00
Server.listen(process.env.PORT ?? 12345, () => log(`Server started and listening on port ${process.env.PORT}.`))