nfp_sites/nfp_is/api/serve.mjs
Jonatan Nilsson 972dde2c74
All checks were successful
/ nfp_moe (push) Successful in -83h47m27s
continuous-integration/appveyor/branch AppVeyor build succeeded
/ saproxy (push) Successful in -83h47m29s
/ discord_embed (push) Successful in -83h47m28s
/ nfp_is (push) Successful in -83h46m7s
nfp_is: moved nfpis over here
2023-11-05 05:38:10 +00:00

20 lines
531 B
JavaScript

import path from 'path'
import Parent from '../base/serve.mjs'
import fs from 'fs/promises'
import config from '../base/config.mjs'
export default class ServeHandler extends Parent {
loadTemplate(indexFile) {
this.template = indexFile.toString()
}
async serveIndex(ctx) {
if (config.get('NODE_ENV') === 'development') {
let indexFile = await fs.readFile(path.join(this.root, 'index.html'))
this.loadTemplate(indexFile)
}
ctx.body = this.template
ctx.type = 'text/html; charset=utf-8'
}
}