28 lines
726 B
JavaScript
28 lines
726 B
JavaScript
|
import express from 'express'
|
||
|
import dotenv from 'dotenv'
|
||
|
import api from './api/api.js'
|
||
|
import { generateDB } from "./db/generate.js"
|
||
|
import { sqlite, dbInit } from "./db/init.js"
|
||
|
import { ddnssStart, scrapeServer } from './ddnss/handler.js'
|
||
|
|
||
|
/* Read the .env file */
|
||
|
dotenv.config()
|
||
|
|
||
|
/* Init db */
|
||
|
dbInit()
|
||
|
|
||
|
/* check if the table points exists */
|
||
|
const exists = sqlite.prepare(`SELECT count(*) as a FROM sqlite_master WHERE type='table' AND name='points'`).get()
|
||
|
|
||
|
/* Generate the DB if false */
|
||
|
if(!exists.a)
|
||
|
generateDB()
|
||
|
|
||
|
|
||
|
/* Init express */
|
||
|
const Server = express()
|
||
|
Server.use('/api', api)
|
||
|
|
||
|
Server.listen(process.env.PORT, () => console.log(`Server started and listening on port ${process.env.PORT}.`))
|
||
|
|
||
|
//ddnssStart()
|