From 196b6ba241fd171ddaef30635d065cb76254b6df Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 22:58:24 +0200 Subject: [PATCH] typescript(translucid): deleted ts files Signed-off-by: prescientmoon --- typescript/translucid/QuickServer.ts | 26 ------------- typescript/translucid/Translucid.ts | 58 ---------------------------- typescript/translucid/app.ts | 5 --- typescript/translucid/test.ts | 12 ------ 4 files changed, 101 deletions(-) delete mode 100644 typescript/translucid/QuickServer.ts delete mode 100644 typescript/translucid/Translucid.ts delete mode 100644 typescript/translucid/app.ts delete mode 100644 typescript/translucid/test.ts diff --git a/typescript/translucid/QuickServer.ts b/typescript/translucid/QuickServer.ts deleted file mode 100644 index 33b7652..0000000 --- a/typescript/translucid/QuickServer.ts +++ /dev/null @@ -1,26 +0,0 @@ -const express = require('express'); -const http = require('http'); - -import {Translucid} from "./Translucid"; - -interface Server{ - app:any, - server:any, - connect:Promise -} - -function QuickServer(port:number):any{ - const app = express(); - const server = http.Server(app); - const translucid = new Translucid(app); - return { - express,app,http,server,translucid, - connect:new Promise((resolve,reject) => { - server.listen(port,() => { - resolve("Connected"); - }); - }) - } -} - -export {QuickServer}; diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts deleted file mode 100644 index e6578a4..0000000 --- a/typescript/translucid/Translucid.ts +++ /dev/null @@ -1,58 +0,0 @@ -import {read} from "./read"; - -interface Midleware{ - name:string; - run:Function; - keys:Array; -} - -function containsAny(array:Array,keys:Array):boolean{ - for (let i = 0;i < keys.length;i++){ - if (array.indexOf(keys[i]) != -1) return true; - } - return false; -} - -class Translucid{ - midleware:Array = []; - constructor(public app){ - } - use(obj:Midleware):void{ - this.midleware.push(obj); - } - bind(path:string="/",filepath:string="", - text:boolean=false,classes:Array=[]):void{ - this.app.get(path,async (req,res) => { - if (!text){ - res.sendFile(`${__dirname}/${filepath}`); - } - else{ - const readResults = await 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]); - }); - } - - decorated.push((prev) => { - res.send(prev + "
Sent from the last iteration"); - }); - - decorated[0](readResults); - } - }); - } -} - -export {Translucid}; diff --git a/typescript/translucid/app.ts b/typescript/translucid/app.ts deleted file mode 100644 index 06a7e9d..0000000 --- a/typescript/translucid/app.ts +++ /dev/null @@ -1,5 +0,0 @@ -import {read} from "./read"; -import {Translucid} from "./Translucid.js"; -import {QuickServer} from "./QuickServer.js" - -export {read,Translucid,QuickServer}; diff --git a/typescript/translucid/test.ts b/typescript/translucid/test.ts deleted file mode 100644 index 8d5b0a0..0000000 --- a/typescript/translucid/test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {QuickServer,Translucid} from "./app"; - -const {app,translucid} = QuickServer(8000); -translucid.bind("/","index.html"); -translucid.bind("/test","read.js",true,["class"]); -translucid.use({ - name:"wow, a midleware", - run:(prev,req,res,next) => { - next("sent by a midleware"); - }, - keys:["class"] -});