How to use the common-errors.middleware function in common-errors

To help you get started, we’ve selected a few common-errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DaVarga / slingxdcc / server.js View on Github external
var app = module.exports = express();


        /**
         * Configuration
         */

            // all environments
        app.set('port', nconf.get('webserver:port'));
        app.set('views', __dirname + '/views');
        app.set('view engine', 'jade');

//        app.use(morgan('dev'));
        app.use(bodyParser.json());
        app.use(bodyParser.urlencoded({extended:false}));
        app.use(errors.middleware.crashProtector());
        app.use(methodOverride());
        app.use(express.static(path.join(__dirname, 'public')));
        app.use(log4js.connectLogger(httpLogger, { level: 'auto', format: ':remote-addr - :method :url HTTP/:http-version :status - :response-time ms',nolog: '\\.gif|\\.jpg$' }));
        
        /**
         * Routes
         */

        app.get('/', routes.index);
        app.get('/partials/:name', routes.partials);

        // JSON API

        app.get('/api/packet/', api.getNumPackets);

        app.get('/api/packet/get/:id', api.packet);
github getlackey / lackey-cms / lib / server / init / errors.js View on Github external
module.exports = (server) => {

    SCli.debug('lackey-cms/server/init/errors', 'Setting up');

    // If we got to this point there was no handler for this request
    server.use(module.exports.notFound);

    // Just in Case... Catch all!
    server.use(errors.middleware.crashProtector());
};
/* istanbul ignore next : external */
github DaVarga / slingxdcc / server.js View on Github external
app.put('/api/downloads/cancel', api.cancelDownload);



        app.post('/api/server/', api.addServer);
        app.post('/api/downloads/', api.startDownload);
        app.post('/api/db/compacting/', api.startCompactCronjob);

        app.delete('/api/server/:key', api.removeServer);
        app.delete('/api/downloads/notifications/', api.clearDlNotifications);
        app.delete('/api/downloads/notifications/count/', api.clearDlNotificationCount);
        app.delete('/api/db/compacting', api.stopCompactCronjob);

        app.get('*', routes.index);

        app.use(errors.middleware.errorHandler);


        /**
         * Create server
         */


        fs.readFile(nconf.get('webserver:ssl.key'), function (errorkey, key){
            fs.readFile(nconf.get('webserver:ssl.crt'), function (errorcrt, crt){
                var server;
                if ((errorcrt || errorkey) && nconf.get('webserver:ssl')){
                    server = http.createServer(app);
                    appLogger.info('No key or cert found, !!!Fallback!!! to Http');
                }else if(nconf.get('webserver:ssl')){
                    server = https.createServer({key: key, cert: crt}, app);
                }else{