ddstats-server/index.js

22 lines
553 B
JavaScript
Raw Normal View History

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-09-29 20:29:06 +02:00
import sqlite2mongo from './libs/database/sqlite2mongo.js'
import databaseInit from './libs/database/init.js'
import initLog from './libs/utills/log.js'
2021-10-03 19:00:41 +02:00
import api from './api/api.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
const Server = express()
2021-10-03 19:00:41 +02:00
Server.use('/api', api)
2021-09-25 12:11:27 +02:00
2021-09-29 20:29:06 +02:00
await databaseInit()
2021-10-03 19:00:41 +02:00
if (process.env.LOAD_DB === "true")
await sqlite2mongo()
2021-09-25 17:47:05 +02:00
2021-09-29 20:29:06 +02:00
Server.listen(process.env.PORT, () => log(`Server started and listening on port ${process.env.PORT}.`))