1
Fork 0

typescript(translucid): added sendFiles option to json

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-01-22 22:18:43 +02:00 committed by prescientmoon
parent 53351b93c9
commit 9afe56a038
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
2 changed files with 9 additions and 8 deletions

View file

@ -25,12 +25,13 @@ class Translucid {
const object = JSON.parse(json);
for (let i in object) {
const classes = object[i].classes || [];
this.bind(i, object[i].file, classes);
//gotta comment this later
// console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`)
const sendAsFiles = object[i].sendFiles;
if (sendFiles != false)
sendFiles = true;
this.bind(i, object[i].file, classes, sendFiles);
}
}
bind(path = "/", filepath = "", classes = [], sendFiles = false) {
bind(path = "/", filepath = "", classes = [], sendFiles = true) {
this.app.get(path, async (req, res) => {
const readResults = await read_1.read(filepath);
const toRun = [];

View file

@ -30,12 +30,12 @@ class Translucid {
for (let i in object){
const classes = object[i].classes || [];
this.bind(i,object[i].file,classes);
//gotta comment this later
// console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`)
const sendAsFiles = object[i].sendFiles;
if (sendFiles != false) sendFiles = true;
this.bind(i,object[i].file,classes,sendFiles);
}
}
bind(path:string = "/", filepath:string = "", classes:Array<string> = [],sendFiles:boolean=false):void{
bind(path:string = "/", filepath:string = "", classes:Array<string> = [],sendFiles:boolean=true):void{
this.app.get(path, async (req, res)=> {
const readResults = await read(filepath);
const toRun:Array<Function> = [];