1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-12-07 23:23:49 +02:00

improving routing. injecting user information to client side to prevent false routing

This commit is contained in:
Braun Patrik
2016-04-09 18:06:29 +02:00
parent 0cfa60143a
commit 65d88fe061
12 changed files with 83 additions and 29 deletions

View File

@@ -5,15 +5,24 @@ import {RenderingMWs} from "../middlewares/RenderingMWs";
export class ErrorRouter{
constructor(private app) {
this.addError();
this.addApiErrorHandler();
}
private addError() {
private addApiErrorHandler() {
this.app.use("/api/*",
RenderingMWs.renderError
);
};
private addGenericHandler() {
this.app.use((err, req, res, next) => {
res.status(500).send('Houston, we have a problem!');
//Flush out the stack to the console
console.error(err.stack);
});
}