qwik-cms/index.js

33 lines
543 B
JavaScript
Raw Normal View History

2021-07-27 19:24:51 +02:00
import express from 'express'
import njk from 'nunjucks'
import fs from 'fs'
const ConfigFile = await fs.readFileSync('./config.json')
const Config = JSON.parse(ConfigFile)
const Server = express()
Server.use('/assets', express.static(Config.assetsDir))
njk.configure(
Config.contentDir,
{
autoescape: true,
express: Server
}
)
Server.get('*', (req, res) => {
res.send(req.url)
})
Server.listen(
Config.serverPort,
() => {
console.log(`Started server on ${Config.serverPort}.`)
}
)