let assert = require('assert')
let cookie = require('cookie')
let crypto = require('crypto')
+let jst_server = (await import('@ndcode/jst_server')).default
let logjson = (await import('@ndcode/logjson')).default
//let NodeMailerCache = require('@ndcode/nodemailer_cache')
let XDate = require('xdate')
let ZettairCache = require('@ndcode/zettair_cache')
return async (resources, root, prev_site) => {
- class CustomSite extends _jst_server.Site {
+ class CustomSite extends jst_server.Site {
constructor(resources, root, options, prev_site) {
super(resources, root, options, prev_site)
this.database = undefined
// called when the server starts or the site.jst file is modified
// in latter case it will carry over the previously created resource objects
async start() {
- await _jst_server.Site.prototype.start.call(this)
+ await super.start()
assert(this.database === undefined)
this.database = await this.resources.ref(
// first and then the stop() method of the old CustomSite object, so that the
// reference counting can keep the resource objects alive during changeover
async stop() {
- await _jst_server.Site.prototype.stop.call(this)
+ await super.stop()
assert(this.database !== undefined)
await this.resources.unref('database')
// called once per second, responsible for cache cleaning and flushing
async kick() {
- await _jst_server.Site.prototype.kick.call(this)
+ await super.kick()
assert(this.database !== undefined)
await this.database.kick()
env.parsed_url.pathname === '/package.json' ||
env.parsed_url.pathname === '/package-lock.json'
) {
- this.die(env, `banned file ${env.parsed_url.pathname}`)
- return
+ throw new jst_server.Problem(
+ 'Not found',
+ `Banned file \"${env.parsed_url.pathname}\"`,
+ 404
+ )
}
- return /*await*/ _jst_server.Site.prototype.respond.call(this, env)
+ return /*await*/ super.respond(env)
}
}
- return new CustomSite(
- resources,
- root,
- {},
- prev_site
- )
+ return new CustomSite(resources, root, {}, prev_site)
}