How to use errorhandler - 10 common examples

To help you get started, we’ve selected a few errorhandler 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 CloudTask / cloudtask-web / src / server / index.js View on Github external
//     error.statusCode = 401;
//     return next(error);
//   }
// });

app.use('/', express.static('dist/client'));
app.use('/api/users', require('./routers/user'));
app.use('/api/dashboard', require('./routers/dashboard'));
app.use('/api/group', require('./routers/group'));
app.use('/api/location', require('./routers/location'));
app.use('/api/job', require('./routers/job'));
app.use('/api/file', require('./routers/file'));
app.use('/api/log', require('./routers/log'));
// app.use('/api/sysconfig', require('./routers/sysconfig'));

errorHandler.title = `Cloudtask WebSite`;
app.use(errorHandler({ log: false }));

user.initAdmin()
  .then(() => {
    app.listen(config.listenPort, () => {
      console.log(`Humpback Website is started on port ${config.listenPort}`);
    });
  })
  .catch(err => {
    console.log(`System init failed. Error: ${err}`);
    process.exit(-101);
  });


  // app.listen(config.listenPort, () => {
  //   console.log(`Website is started on port ${config.listenPort}`);
github quran / quran.com-frontend / src / server.js View on Github external
return res.send(html);
          })
          .catch(next);
      }
    }
  );

  return false;
});

server.use(Raven.errorHandler());

if (process.env.NODE_ENV === 'development') {
  // only use in development
  server.use(errorhandler());
} else {
  server.use((req, res) => {
    res.status(500);
    res.send('OOPS');
  });
}

const port = process.env.PORT || 8000;

export default function serve(cb) {
  return server.listen(port, () => {
    console.info(`==> 🌎  ENV=${process.env.NODE_ENV}`);
    console.info(`==> ✅  Server is listening at http://localhost:${port}`);
    console.info(`==> 🎯  API at ${process.env.API_URL}`);
    Object.keys(config).forEach(
      key =>
github bkimminich / juice-shop / server.js View on Github external
error = null
      }
      cb(error, './frontend/dist/frontend/assets/public/images/uploads/')
    },
    filename: (req, file, cb) => {
      const name = insecurity.sanitizeFilename(file.originalname)
        .toLowerCase()
        .split(' ')
        .join('-')
      const ext = mimeTypeMap[file.mimetype]
      cb(null, name + '-' + Date.now() + '.' + ext)
    }
  })
})

errorhandler.title = `${config.get('application.name')} (Express ${utils.version('express')})`

/* Locals */
app.locals.captchaId = 0
app.locals.captchaReqId = 1
app.locals.captchaBypassReqTimes = []
app.locals.abused_ssti_bug = false
app.locals.abused_ssrf_bug = false

/* Compression for all requests */
app.use(compression())

/* Bludgeon solution for possible CORS problems: Allow everything! */
app.options('*', cors())
app.use(cors())

/* Security middleware */
github adelciotto / multiplayer-mario / src / server / express_server.js View on Github external
_configureExpress(dirname) {
        this.app.use(express.static(path.join(dirname, '/dist')));

        // enable development mode by default to aid with debugging.
        var env = process.env.NODE_ENV || 'development';
        if ('development' == env) {
          this.app.use(errorHandler());
        }
    }
}
github quran / quran.com-frontend / src / server / server.js View on Github external
res.setHeader('Cache-Control', 'public, max-age=31557600');

      res.status(context.status || 200);

      return res.send(html);
    });
  });

  return false;
});

server.use(Raven.errorHandler());

if (process.env.NODE_ENV === 'development') {
  // only use in development
  server.use(errorhandler());
} else {
  server.use((req, res) => {
    res.status(500);
    res.send('OOPS');
  });
}

const port = process.env.PORT || 8000;

server.listen(port, () => {
  log({
    title: 'server',
    level: 'special',
    message: `✓

      ${config('welcomeMessage')}
github rcos / observatory-server / server / config / express.js View on Github external
if ('production' === env) {
    app.use(favicon(path.join(config.root, 'client', 'favicon.ico')));
    app.use(express.static(app.get('appPath')));
    app.use(morgan('common'));
  }

  if ('development' === env) {
    app.use(require('connect-livereload')());
  }

  if ('development' === env || 'test' === env) {
    app.use(express.static(path.join(config.root, '.tmp')));
    app.use(express.static(app.get('appPath')));
    app.use(morgan('dev'));
    app.use(errorHandler()); // Error handler - has to be last
  }
}
github humpback / humpback-web / src / server / index.js View on Github external
return next();
  } else {
    error = new Error('UnAuthorization. Not login.');
    error.statusCode = 401;
    return next(error);
  }
});

app.use('/api/users', require('./routers/user'));
app.use('/api/groups', require('./routers/group'));
app.use('/api/images', require('./routers/imageInfo'));
app.use('/api/logs', require('./routers/log'));
app.use('/api/system-config', require('./routers/systemConfig'));
app.use('/api/dashboard', require('./routers/dashboard'));

errorHandler.title = `Humpback WebSite - ${config.version}`;
app.use(errorHandler({ log: false }));

console.debug('Init system...');
user.initAdmin()
  .then(() => {
    app.listen(config.listenPort, () => {
      console.debug('Init system succeed');
      console.log(`Humpback Website is started on port ${config.listenPort}`);
    });
  })
  .catch(err => {
    console.log(`System init failed. Error: ${err}`);
    process.exit(-101);
  });
github yubowenok / visflow / server / src / server.ts View on Github external
import errorHandler from 'errorhandler';

import app, { appShutdown } from './app';
import { ENVIRONMENT } from './config/env';

if (ENVIRONMENT !== 'production') {
  app.use(errorHandler());
}

const server = app.listen(app.get('port'), () => {
  console.log('Server running at http://localhost:%d in %s mode', app.get('port'), app.get('env'));
});

const shutdown = () => {
  server.close(appShutdown);
};

process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);

export default server;
github minimal-studio / web-server / src / index.ts View on Github external
createConnection().then(() => {
  /**
   * Error Handler. Provides full stack - remove for production
   */
  app.use(errorHandler());

  /**
   * Start Express server.
   */
  app.listen(Port, () => {
    console.log(
      "  App is running at http://localhost:%d in %s mode",
      Port,
      app.get("env")
    );
    console.log("  Press CTRL-C to stop\n");
  });
}).catch(error => console.log(error));

errorhandler

Development-only error handler middleware

MIT
Latest version published 6 years ago

Package Health Score

76 / 100
Full package analysis

Similar packages