diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 26b4b56..85d6479 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -30,7 +30,7 @@ class Translucid { // console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) } } - bind(path = "/", filepath = "", classes = []) { + bind(path = "/", filepath = "", classes = [], sendFiles = false) { this.app.get(path, async (req, res) => { const readResults = await read_1.read(filepath); const toRun = []; @@ -47,11 +47,12 @@ class Translucid { }); } decorated.push((prev) => { - // console.log(`${__dirname}/../../${filepath}`); - res.contentType(`${__dirname}/../../${filepath}`); - res.send(prev); + if (!sendFiles) + res.send(prev); + else + res.sendFile(prev); }); - decorated[0](readResults); + decorated[0](sendfiles ? readResults : `${__dirname}/../../${filepath}`); }); } } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 9a408c8..de706fd 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -35,7 +35,7 @@ class Translucid { // console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) } } - bind(path:string = "/", filepath:string = "", classes:Array = []):void{ + bind(path:string = "/", filepath:string = "", classes:Array = [],sendFiles:boolean=false):void{ this.app.get(path, async (req, res)=> { const readResults = await read(filepath); const toRun:Array = []; @@ -55,12 +55,13 @@ class Translucid { }); } decorated.push((prev:any):void => { - // console.log(`${__dirname}/../../${filepath}`); - res.contentType(`${__dirname}/../../${filepath}`); - res.send(prev); + if (!sendFiles) + res.send(prev); + else + res.sendFile(prev); }); - decorated[0](readResults); + decorated[0](sendfiles?readResults:`${__dirname}/../../${filepath}`); }); } }