How to use the NotAcceptable function from http-errors
Find comprehensive JavaScript http-errors.NotAcceptable code examples handpicked from public code repositorys.
39 40 41 42 43 44 45 46 47 48
methodNotAllowed: function methodNotAllowed (message) { return new createError.MethodNotAllowed(message) }, notAcceptable: function notAcceptable (message) { return new createError.NotAcceptable(message) }, proxyAuthenticationRequired: function proxyAuthenticationRequired (message) { return new createError.ProxyAuthenticationRequired(message)
30
340
17
+ 55 other calls in file
146 147 148 149 150 151 152 153 154 155
module.exports.BadRequest = new HTTPErrors.BadRequest() module.exports.Unauthorized = new HTTPErrors.Unauthorized() module.exports.Forbidden = new HTTPErrors.Forbidden() module.exports.NotFound = new HTTPErrors.NotFound() module.exports.MethodNotAllowed = new HTTPErrors.MethodNotAllowed() module.exports.NotAcceptable = new HTTPErrors.NotAcceptable() module.exports.ProxyAuthenticationRequired = new HTTPErrors.ProxyAuthenticationRequired() module.exports.RequestTimeout = new HTTPErrors.RequestTimeout() module.exports.Conflict = new HTTPErrors.Conflict() module.exports.Gone = new HTTPErrors.Gone()
1
0
7
+ 41 other calls in file
43 44 45 46 47 48 49 50 51 52
throw createError.Conflict("Email or username has already been taken"); } else { // *** Hash user password const hash = await generateHashPassword(result.password); if (!hash) { throw createError.NotAcceptable("Weak password. Try again."); } else { const newUser = await saveNewUser(result, hash); if (!newUser) { throw createError.InternalServerError();
0
1
0
89 90 91 92 93 94 95 96 97 98
const id = req.params.id; if (!id) { throw createError.NotAcceptable("Request params is not present"); } else { if (!req.files) { throw createError.NotAcceptable("No image file is present"); } else { const file = req.files.image; const data = await uploadImage(file); const result = await uploadGroupImage(id, "image", data.url);
0
1
0
+ 5 other calls in file
80 81 82 83 84 85 86 87 88
if (!paramsLength) throw new createErrors.BadRequest('Request parameters empty') const decryptVerificationCode = legacyDecrypt(params.code) const user = await knex.select('*').from('users').where('verification_code', decryptVerificationCode).first() if (!user) throw new createErrors.NotAcceptable('Verification code is not valid') const id = user.id const result = await knex('users').where('id', id).update('verification_code', '').returning('name')
4
2
0
+ 3 other calls in file
84 85 86 87 88 89 90 91 92 93
if (!paramsLength) throw new createErrors.BadRequest('Request parameters empty!') const decryptVerificationCode = legacyDecrypt(params.code) const user = await getUserByIdModels(false, [decryptVerificationCode], 'verification_code = $1') if (!user) throw new createErrors.NotAcceptable('Verification code is not valid!') const id = user.id const queryAdditionalDatabase = 'verification_code = \'\' WHERE id = $1' const result = await putUserModels(false, [id], queryAdditionalDatabase)
0
0
0
+ 23 other calls in file
183 184 185 186 187 188 189 190 191 192
template: true, }, }); if (!pin) throw new createErrors.NotAcceptable("OTP Session was not found"); const expiryTime = moment .tz(SERVER_TIMEZONE) .utc()
0
0
0
+ 7 other calls in file
49 50 51 52 53 54 55 56 57
user.email, "Your account has login in other IP", "We detected your account has login in other IP. Please check it." ); throw createError.NotAcceptable("Your ip has change. Please login again."); } if (!user) throw createError.Unauthorized("User dose not exists in database.");
0
0
0
GitHub: ericlowry/swat
46 47 48 49 50 51 52 53 54 55
tokenAuthorization, hasRole('user'), async (req, res) => { const debug = _debug('api:is-unique'); const { db, view, key } = req.params; if (!db || !view || !key) throw new NotAcceptable('invalid path'); const uri = `${APPLICATION_ID}-${db}` + `/_design/${APPLICATION_ID}-api` + `/_view/${view}` +
0
0
0
73 74 75 76 77 78 79 80 81 82
case 405: { httpError = createError.MethodNotAllowed(); break; } case 406: { httpError = createError.NotAcceptable(); break; } case 407: { httpError = createError.ProxyAuthenticationRequired();
0
0
2
+ 41 other calls in file
http-errors.NotFound is the most popular function in http-errors (1819 examples)