// catch 404 and forward to error handler app.use(function(req, res, next) { next(createError(404)); });
router.post('/', async (req, res, next) => { if (!/.+@.+\..+/.test(req.body.email) || !(req.body.password && /.+/.test(req.body.password))) { return next(createError(400, 'Email and password are required')); } res.status(201).json( await createUser(req.body.email, req.body.password) ); });
router.get('/:id', ensureAuth(), async (req, res, next) => { if (req.user.sub !== req.params.id) next(createError(401)); const user = await fetchUser(req.params.id); user ? res.json(user) : next(createError(404)); });
// mock data app.use('/values', (req, res, next) => { if (req.method !== "GET") { return next(createError(405)); } res.send(["value3", "value5", "value7", "value9", "value11"]).end(); });
//------------------------------------- // // catch 404 and forward to error handler // //------------------------------------- app.use(function (req, res, next) { next(createError(404)); });
//------------------------------------- // // catch 404 and forward to error handler // //------------------------------------- app.use(function (req, res, next) { next(createError(404)); });
//------------------------------------- // // catch 404 and forward to error handler // //------------------------------------- app.use(function (req, res, next) { next(createError(404)); });
//------------------------------------- // // catch 404 and forward to error handler // //------------------------------------- app.use(function (req, res, next) { next(createError(404)); });
//------------------------------------- // // catch 404 and forward to error handler // //------------------------------------- app.use(function (req, res, next) { next(createError(404)); });
//------------------------------------- // // catch 404 and forward to error handler // //------------------------------------- app.use(function (req, res, next) { next(createError(404)); });
// No others route map // Create error app.use((req, res, next) => { return next(createError(404, 'File not found')); });
///////////// // ERRORS // /////////// // catch 404 and forward to error handler app.use(function(req, res, next) { next(createError(404)); });
//------------------------------------- // // catch 404 and forward to error handler // //------------------------------------- app.use(function (req, res, next) { next(createError(404)); });
//------------------------------------- // // catch 404 and forward to error handler // //------------------------------------- app.use(function (req, res, next) { next(createError(404)); });
//------------------------------------- // // catch 404 and forward to error handler // //------------------------------------- app.use(function (req, res, next) { next(createError(404)); });