Make /_config/*.jst use ES6 superclass calls, fix failure to await the superclass... master
authorNick Downing <nick@ndcode.org>
Wed, 26 Jan 2022 23:28:03 +0000 (10:28 +1100)
committerNick Downing <nick@ndcode.org>
Wed, 26 Jan 2022 23:35:26 +0000 (10:35 +1100)
.gitignore
_config/server.jst
_config/site.jst
link.sh [new file with mode: 0755]
package.json

index f24f5f8..1c0633e 100644 (file)
@@ -5,4 +5,4 @@
 .*.min
 .*.svg
 /node_modules
-/pnpm-lock.yaml
+/package-lock.json
index e6ebffc..f0cd853 100644 (file)
@@ -1,4 +1,6 @@
-return async (resources, prev_server) => new _jst_server.Server(
+let jst_server = (await import('@ndcode/jst_server')).default
+
+return async (resources, prev_server) => new jst_server.Server(
   resources,
   {
     hosts: {
index 62d01af..6d56a2f 100644 (file)
@@ -1,18 +1,19 @@
+let assert = require('assert')
+let jst_server = (await import('@ndcode/jst_server')).default
 //let EmailJSCache = require('@ndcode/emailjs_cache')
 //let ZettairCache = require('@ndcode/zettair_cache')
-let assert = require('assert')
 
 return async (resources, root, prev_site) => {
-  class CustomSite extends _jst_server.Site {
-    constructor(resources, root, options, prev_site) {
-      super(resources, root, options, prev_site)
-
-      this.emailjs_cache = undefined
-      this.zettair_cache = undefined
-    }
-
+  class CustomSite extends jst_server.Site {
+    //constructor(resources, root, options, prev_site) {
+    //  super(resources, root, options, prev_site)
+    //
+    //  this.emailjs_cache = undefined
+    //  this.zettair_cache = undefined
+    //}
+    //
     //async start() {
-    //  await _jst_server.Site.prototype.start.call(this)
+    //  await super.start()
     //
     //  assert(this.emailjs_cache === undefined)
     //  this.emailjs_cache = await this.resources.ref(
@@ -28,7 +29,7 @@ return async (resources, root, prev_site) => {
     //}
     //
     //async stop() {
-    //  await _jst_server.Site.prototype.stop.call(this)
+    //  await super.stop()
     //
     //  assert(this.emailjs_cache !== undefined)
     //  await this.resources.unref('emailjs_cache')
@@ -38,7 +39,7 @@ return async (resources, root, prev_site) => {
     //}
     //
     //async kick() {
-    //  await _jst_server.Site.prototype.kick.call(this)
+    //  await super.kick()
     //
     //  assert(this.emailjs_cache !== undefined)
     //  this.emailjs_cache.kick()
@@ -61,17 +62,15 @@ return async (resources, root, prev_site) => {
         env.parsed_url.pathname.slice(0, 14) === '/node_modules/' ||
         env.parsed_url.pathname === '/package.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)
 }
diff --git a/link.sh b/link.sh
new file mode 100755 (executable)
index 0000000..76c2ff9
--- /dev/null
+++ b/link.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+rm -rf node_modules package-lock.json
+npm link @ndcode/jst_server
+npm install
+npm link
index 1337735..843b807 100644 (file)
@@ -4,6 +4,7 @@
   "description": "Olly's website",
   "directories": {},
   "dependencies": {
+    "@ndcode/jst_server": "^0.1.0",
     "cookie": "^0.3.1",
     "querystring": "^0.2.0",
     "stream-buffers": "^3.0.2",