nfp_sites/nfp_is/api/serve.mjs
Jonatan Nilsson 186b1d6218
All checks were successful
/ discord_embed (push) Successful in -83h48m36s
continuous-integration/appveyor/branch AppVeyor build succeeded
/ nfp_moe (push) Successful in -83h48m38s
/ saproxy (push) Successful in -83h48m37s
nfp_is: moved nfpis over here
2023-11-05 05:24:25 +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'
}
}