From 62bf58898e96f4545e833d6773ee8d0b40addb6c Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:57:11 +0200 Subject: [PATCH] typescript(translucid): deprecations Signed-off-by: prescientmoon --- typescript/translucid/README.md | 2 +- typescript/translucid/Translucid.js | 35 +++++++++++++---------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md index 6aba50f..12fa6b4 100644 --- a/typescript/translucid/README.md +++ b/typescript/translucid/README.md @@ -30,7 +30,7 @@ connect.then(() => { ``` The translucid object can be used to make file bindings: ``` -translucid.bind("/","client/index.html",true,["myId"]); +translucid.bind("/","client/index.html",["myId"]); ``` Then you can add middleware like this: ``` diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 469d941..3f464ec 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -16,31 +16,26 @@ class Translucid { use(obj) { this.midleware.push(obj); } - bind(path = "/", filepath = "", text = false, classes = []) { + bind(path = "/", filepath = "", classes = []) { this.app.get(path, async (req, res) => { - if (!text) { - console.error("Blocking reading acces s deprecated, and would be remove in the next version."); + const readResults = await read_1.read(filepath); + const toRun = []; + for (let i of this.midleware) { + if (containsAny(classes, i.keys)) { + toRun.push(i.run); + } } - else { - const readResults = await read_1.read(filepath); - const toRun = []; - for (let i of this.midleware) { - if (containsAny(classes, i.keys)) { - toRun.push(i.run); - } - } - const decorated = []; - const expressArgs = [req, res]; - for (let i = 0; i < toRun.length; i++) { - decorated.push((prev) => { - toRun[i](prev, ...expressArgs, decorated[i + 1]); - }); - } + const decorated = []; + const expressArgs = [req, res]; + for (let i = 0; i < toRun.length; i++) { decorated.push((prev) => { - res.send(prev); + toRun[i](prev, ...expressArgs, decorated[i + 1]); }); - decorated[0](readResults); } + decorated.push((prev) => { + res.send(prev); + }); + decorated[0](readResults); }); } }