How to use the BadRequestError function from restify
Find comprehensive JavaScript restify.BadRequestError code examples handpicked from public code repositorys.
36 37 38 39 40 41 42 43 44
let employeeId = req.params.employeeId; let pictureType = req.query.pictureType || '1'; if (!employeeId) { res.send(new restify.BadRequestError('Invalid employee id')); next(); return; }
69
95
21
236 237 238 239 240 241 242 243 244
/* * Restify handler for handling form uploads. */ function upload(request, response, next) { next(new mod_restify.BadRequestError('Unauthorized')); } main();
8
77
12
+ 3 other calls in file
35 36 37 38 39 40 41 42 43
var errorHandling = function (err) { log.error(err); if (err.fatal) { return new restify.ServiceUnavailableError('Database Fatal Error: ' + err.code); } else if (err.code === 'ER_DUP_ENTRY') { return new restify.BadRequestError('Request can not accomplished, cause of duplicate entrys in the database'); } return new restify.UnprocessableEntityError('Database query failed: ' + err.code); };
1
2
2
+ 3 other calls in file
GitHub: shades-io/shades
4 5 6 7 8 9 10 11 12 13
'use strict'; const restify = require('restify'); const snakeCase = require('snake-case'); const BadRequest = restify.BadRequestError; const ServiceUnavailable = restify.ServiceUnavailableError; const Router = require('../utils/route.js'); const router = new Router();
0
1
2
GitHub: diamondpkg/registry
74 75 76 77 78 79 80 81 82
res.write(body); return res.end(); }); router.post('/user', (req, res) => { if (!req.params.username || !req.params.password || !req.params.email) return res.send(new restify.BadRequestError('Missing username and/or password and/or email')); bcrypt.hash(req.params.password, 8, async (err, hash) => { if (err) return res.send(new restify.InternalServerError('Internal server error'));
0
1
2
+ 3 other calls in file
GitHub: pglah/openSenseMap-API
208 209 210 211 212 213 214 215 216 217
} if (typeof req.params['sensorId'] !== 'undefined') { let sensorId = req.params['sensorId'].toString(); if (sensorId && !mongoose.Types.ObjectId.isValid(sensorId)) { next(new restify.BadRequestError('Parameter :sensorId is not valid')); } } next(); });
36
0
0
+ 3 other calls in file
restify.createServer is the most popular function in restify (1059 examples)