Skip to content

Commit

Permalink
Merge pull request #30 from mzch/master
Browse files Browse the repository at this point in the history
Fix 2 bugs
  • Loading branch information
diced authored Sep 20, 2020
2 parents 9d57b15 + beb8273 commit c1c096c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/controllers/APIController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class APIController {
if (config.uploader.blacklistedExt.includes(req.file.originalname.split('.').pop())) return res.status(BAD_REQUEST).json({ code: BAD_REQUEST, message: 'The extension used in this file is blacklisted.' })
const source = createReadStream(req.file.path);
if (!existsSync(config.uploader.upload)) mkdirSync(config.uploader.upload);
const destination = createWriteStream(`${config.upload.uploadDir}${sep}${id}.${req.file.originalname.split('.').pop()}`);
const destination = createWriteStream(`${config.uploader.upload}${sep}${id}.${req.file.originalname.split('.').pop()}`);
source.pipe(destination, { end: false });
source.on("end", function () {
unlinkSync(req.file.path);
Expand Down
4 changes: 2 additions & 2 deletions src/entities/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class User {
this.username = options.username;
this.password = options.password;
this.administrator = options.administrator;
this.token = randomId(config.user.tokenLength)
this.token = randomId(config.core.userTokenLength)
return this;
}
}
}
7 changes: 6 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ const config = JSON.parse(fs.readFileSync(findFile('config.json', process.cwd())
export class ZiplineServer extends Server {
constructor(orm: ORMHandler) {
super();
this.app.set("view engine", "ejs");
var p = 'loopback';
if (config.core.trustedProxy) {
p += ',' + config.core.trustedProxy;
}
this.app.set("trust proxy", p);
this.app.set("view engine", "ejs");
this.app.use(
session({
secret: config.core.sessionSecret,
Expand Down

0 comments on commit c1c096c

Please sign in to comment.