Updates
h3rald h3rald@h3rald.com
Sat, 22 Feb 2020 18:37:55 +0100
3 files changed,
12 insertions(+),
18 deletions(-)
M
src/litestorepkg/examples/config.json
→
src/litestorepkg/examples/config.json
@@ -1,13 +1,15 @@
{ "settings": { - "mount": true, - "directory": "admin" + "log": "debug" }, "resources": { "/info": { "GET": { "auth": ["admin:server"] } }, "/docs/*": { + "GET": { + "middleware": ["test"] + }, "POST": { "auth": ["admin:server"] }, "PATCH": { "auth": ["admin:server"] }, "PUT": { "auth": ["admin:server"] },
M
src/litestorepkg/examples/test.js
→
src/litestorepkg/examples/test.js
@@ -1,3 +1,4 @@
-LiteStore.response.content = LiteStore.api.get('docs').content; - -console.log(LiteStore.api.passthrough());+(function() { + $res.content = $req; + return; +}())
M
src/litestorepkg/lib/api_v6.nim
→
src/litestorepkg/lib/api_v6.nim
@@ -1108,29 +1108,20 @@ return ctx.duk_peval_string("__next__ = true;")
) discard duk_push_c_function(ctx, fNext, 0) discard ctx.duk_put_global_string("$next") - let fAbort: DTCFunction = (proc (ctx: DTContext): cint{.stdcall.} = - return ctx.duk_peval_string("__abort__ = true;") - ) - discard duk_push_c_function(ctx, fAbort, 0) - discard ctx.duk_put_global_string("$abort") var i = 0 ctx.duk_push_boolean(1) discard ctx.duk_put_global_string("__next__") - ctx.duk_push_boolean(0) - discard ctx.duk_put_global_string("__abort__") - var next = 1 var abort = 0 + var next = 0 while abort != 1 and i < middleware.len: if ctx.duk_peval_string("__next__") != 0: return jError(ctx) next = ctx.duk_get_boolean(-1) - if ctx.duk_peval_string("__abort__") != 0: - return jError(ctx) - abort = ctx.duk_get_boolean(-1) if next != 1: - return resError(Http500, "Middleware does not explicitly call $next().") + abort = 1 + LOG.debug("next: $1 | abort: $2", [next, abort]) let code = LS.getMiddleware(middleware[i]) - echo "evaluating code" + LOG.debug("Evaluating middleware '$1'" % middleware[i]) if ctx.duk_peval_string(code) != 0: echo "error!" return jError(ctx)