1
Fork 0

typescript(translucid): fixed forbbiden sendFile

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-01-22 22:35:44 +02:00 committed by prescientmoon
parent 76430ff691
commit 2f229fb449
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
2 changed files with 7 additions and 2 deletions

View file

@ -1,7 +1,9 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const express = require('express'); const express = require('express');
const path = require('path');
const read_1 = require("./read"); const read_1 = require("./read");
const dir = path.dirname(require.main.filename);
function containsAny(array, keys) { function containsAny(array, keys) {
for (let i = 0; i < keys.length; i++) { for (let i = 0; i < keys.length; i++) {
if (array.indexOf(keys[i]) != -1) if (array.indexOf(keys[i]) != -1)
@ -53,7 +55,7 @@ class Translucid {
else else
res.sendFile(prev); res.sendFile(prev);
}); });
decorated[0]((!sendFiles) ? readResults : `${__dirname}/../../${filepath}`); decorated[0]((!sendFiles) ? readResults : `${dir}/${filepath}`);
}); });
} }
} }

View file

@ -1,6 +1,9 @@
const express = require('express'); const express = require('express');
const path = require('path');
import {read} from "./read"; import {read} from "./read";
const dir = path.dirname(require.main.filename);
interface Middleware{ interface Middleware{
name:string; name:string;
keys:Array<string>; keys:Array<string>;
@ -61,7 +64,7 @@ class Translucid {
res.sendFile(prev); res.sendFile(prev);
}); });
decorated[0]((!sendFiles)?readResults:`${__dirname}/../../${filepath}`); decorated[0]((!sendFiles)?readResults:`${dir}/${filepath}`);
}); });
} }
} }