You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
756 B

// .env file
const config = require('dotenv').config()
// logging
const fastify = require('fastify') ({
logger: process.env.DEBUG
})
// path for public
const path = require('path')
// adding files and plugins
fastify
.register(require('./http/web.js'))
.register(require('./api/state.js'), { 'prefix': '/api' })
.register(require('fastify-static'), {
root: path.join(__dirname, '../public'),
prefix: '/public/'
})
// let it rain
const start = async () => {
try {
await fastify.listen(process.env.SERVER_PORT, process.env.SERVER_IP)
fastify.log.info(`server listening on ${fastify.server.address().port}`)
} catch (err) {
fastify.log.error(err)
process.exit(1)
}
}
start()