feat: add logging and error handling

This commit is contained in:
Axel Cocat 2022-02-27 17:46:38 +01:00
parent f324ca45ff
commit 56c0fed144
10 changed files with 720 additions and 49 deletions

View file

@ -44,14 +44,13 @@ export class IndexController {
});
}
public async search(req: express.Request, res: express.Response): Promise<void> {
public async search(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {
const realmName = req.query.realm as string;
const realm = realmName === undefined ?
this.armory.config.realms[0] :
this.armory.config.realms.find(r => r.name === realmName);
if (realm === undefined) {
res.status(400);
return;
return next(400);
}
const db = this.armory.getCharactersDb(realm.name);