ddstats-server/index.js
2021-10-06 20:36:20 +02:00

28 lines
730 B
JavaScript

/**
* This is the entrypoint for 'DDStats'.
* DDStats is a custom API that servers statistics from the DDRace Network-
* @author BurnyLlama <xmpp:burnyllama@qwik.space>
*/
import express from 'express'
import dotenv from 'dotenv'
import sqlite2mongo from './libs/database/sqlite2mongo.js'
import databaseInit from './libs/database/init.js'
import initLog from './libs/utills/log.js'
import api from './api/api.js'
const log = initLog("[ MAIN ]")
// Read the .env file
dotenv.config()
const Server = express()
Server.use('/api', api)
await databaseInit()
if (process.env.LOAD_DB === "true")
await sqlite2mongo()
Server.listen(process.env.PORT, () => log(`Server started and listening on port ${process.env.PORT}.`))