typescript(translucid): i think i fixed it
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
220c6667a3
commit
6349cd4442
|
@ -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}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<string> = []):void{
|
||||
bind(path:string = "/", filepath:string = "", classes:Array<string> = [],sendFiles:boolean=false):void{
|
||||
this.app.get(path, async (req, res)=> {
|
||||
const readResults = await read(filepath);
|
||||
const toRun:Array<Function> = [];
|
||||
|
@ -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}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue