Skip to content

Commit

Permalink
fixed web routes on build
Browse files Browse the repository at this point in the history
  • Loading branch information
Stalker2106x committed Aug 30, 2023
1 parent 663f5f1 commit 35af74d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions routes/web/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const fs = require('fs')
const path = require('path')

module.exports = {
handler: (app, req, res, next) => {
const templatePath = path.join(__dirname, '../../web', 'home.html')
const css = fs.readFileSync(path.join(__dirname, '../../web', 'web.css'), 'utf-8')
handler: async (app, req, res, next) => {
const template = await fs.readFileSync(path.join(__dirname, '../../web', 'home.html'), 'utf-8')
const css = await fs.readFileSync(path.join(__dirname, '../../web', 'web.css'), 'utf-8')
const version = `Server v${app.config.serverVersion} - Game v${app.config.gameVersion}`
const page = nunjucks.configure({ autoescape: false }).render(templatePath, { css, serverList: app.serverList, version })
const page = nunjucks.configure({ autoescape: false }).renderString(template, { css, serverList: app.serverList, version })
res.set('Content-Type', 'text/html; charset=utf-8')
res.send(Buffer.from(page))
}
Expand Down
4 changes: 2 additions & 2 deletions routes/web/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const path = require('path')

module.exports = {
handler: async (app, req, res, next) => {
const templatePath = path.join(__dirname, '../../web', 'register.html')
const template = await fs.readFileSync(path.join(__dirname, '../../web', 'register.html'), 'utf-8')
const css = await fs.readFileSync(path.join(__dirname, '../../web', 'web.css'), 'utf-8')
const registerScript = await fs.readFileSync(path.join(__dirname, '../../web/scripts', 'register.js'), 'utf-8')
const page = nunjucks.configure({ autoescape: false }).render(templatePath, { css, registerScript })
const page = nunjucks.configure({ autoescape: false }).renderString(template, { css, registerScript })
res.set('Content-Type', 'text/html; charset=utf-8')
res.send(Buffer.from(page))
}
Expand Down

0 comments on commit 35af74d

Please sign in to comment.