Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing variables to Kraken error middleware #468

Closed
xShirase opened this issue Jul 6, 2016 · 2 comments
Closed

Passing variables to Kraken error middleware #468

xShirase opened this issue Jul 6, 2016 · 2 comments
Labels
Projects

Comments

@xShirase
Copy link

xShirase commented Jul 6, 2016

I was wondering how to pass a model to middleware 404 and 500? The reason being that my templates need a bunch of dust variables (prod/dev, assets on different cdns, etc) which are all defined in config and passed to the relevant model. It's a single page app, so it's all good except for the error pages.

example :

router.get('*', function(req, res, next){
        var env = req.app.kraken.get('env:env');
        model.cloudfront = req.app.kraken.get('aws:cloudfront_URL');
        model.version = req.app.kraken.get('version:current');
        if (env === 'production') {
            model.production = 1;
        } else if (env === 'staging') {
            model.staging = 1;
        }
        var maintenance = req.app.kraken.get('maintenanceMode:state');
        if(maintenance){
            model = new maintenanceModeModel();
            console.log('maintenance Mode on');
            res.render('maintenanceMode',model);
        }else{
            next();
        }
});

Is there a way to pass an object to the default middleware, or do I have to make custom routes to handle the errors?

@subeeshcbabu-zz
Copy link
Member

404 and 500 middleware are already deprecated. See #359. You should be writing these error handlers as a standard practice (that will provide you more flexibility and control).

@grawk grawk added the question label Dec 24, 2016
@grawk
Copy link
Member

grawk commented Dec 24, 2016

answered

@grawk grawk closed this as completed Dec 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Triage
Doing
Development

No branches or pull requests

3 participants