How to use the Conflict function from http-errors
Find comprehensive JavaScript http-errors.Conflict code examples handpicked from public code repositorys.
51 52 53 54 55 56 57 58 59 60
requestTimeout: function requestTimeout (message) { return new createError.RequestTimeout(message) }, conflict: function conflict (message) { return new createError.Conflict(message) }, gone: function gone (message) { return new createError.Gone(message)
30
340
17
+ 55 other calls in file
GitHub: maniacs-db/arangodb
206 207 208 209 210 211 212 213 214 215
{waitForSync} ); } catch (e) { if (e.isArangoError && e.errorNum === errors.ERROR_GRAPH_DUPLICATE.code) { throw Object.assign( new httperr.Conflict(e.errorMessage), {errorNum: e.errorNum, cause: e} ); } if (e.isArangoError && [
813
0
2
GitHub: mfolkeseth/core
169 170 171 172 173 174 175 176 177
if (!versions.check(pVersion)) { this._log.info( `pkg:put - Semver version is lower than previous version of the package - Org: ${org} - Type: ${type} - Name: ${pName} - Version: ${pVersion}`, ); const e = new HttpError.Conflict(); end({ labels: { success: false, status: e.status, type } }); throw e; }
2
1
1
26 27 28 29 30 31 32 33 34 35
const user = await knex.select('name').from('users').where('email', data.email).first() let result = '' if (!bodyLength) throw new createErrors.BadRequest('Request body empty') if (user) throw new createErrors.Conflict('Account has been registered') const hashPassword = await argon2.hash(data.password, { type: argon2.argon2id }) const randomCode = random(12) const encryptRandomCode = legacyEncrypt(randomCode)
4
2
0
3 4 5 6 7 8 9 10 11 12 13
const sendSubscriptionEmail = async (req, res) => { const { email } = req.body; const { email: emailUser } = req.user; if (email !== emailUser) { throw new Conflict(`Your email: ${email} is not register`); } const subscriptionEmail = { to: email, subject: "Email",
1
0
0
4 5 6 7 8 9 10 11 12 13 14
const register = async (req, res) => { const body = req.body; const { name, email, password } = body; const user = await User.findOne({ email }); if (user) { throw new Conflict(`User with this email: ${email} already exists`); } const hashPassword = bcrypt.hashSync(password, 10); const newUser = await User.create({ name, email, password: hashPassword });
1
0
0
13 14 15 16 17 18 19 20 21 22
'This account is not active. This user most likely needs to activate their account via email, or may have been banned by an administrator.' ) /* User emails related errors */ module.exports.EmailNotFound = new HTTPErrors.NotFound('Email not found') module.exports.ConflictingEmail = new HTTPErrors.Conflict( 'A user already exists with this email' ) module.exports.InvalidActivationToken = new HTTPErrors.Forbidden( 'The supplied email activation token is invalid or has expired'
1
0
7
+ 377 other calls in file
3 4 5 6 7 8 9 10 11 12 13
const signup = async (req, res) => { const { name, email, password } = req.body; const userExists = await User.findOne({ email }); if (userExists) { throw new Conflict(`Email ${email} in use`); } const hashPassword = bcrypt.hashSync(password, bcrypt.genSaltSync(10)); const result = await User.create({ name, email, password: hashPassword }); res.status(201).json({
0
1
0
82 83 84 85 86 87 88 89 90 91
result.password, user.password ); console.log(passwordResult); if (!passwordResult) { throw createError.Conflict("User credential is not correct"); } else { const token = await generateToken(user); if (!token) { throw createError.NotImplemented("Invalid token! please try again");
0
1
0
+ 21 other calls in file
45 46 47 48 49 50 51 52 53 54
} catch (error) { throw createError.InternalServerError(error.message); } } else { if (!title.trim() || !description.trim()) { throw createError.Conflict( "Title & description are minimum requirement to create a note" ); } else { const note = await saveNote(
0
1
0
+ 11 other calls in file
64 65 66 67 68 69 70 71 72 73
// 3. Edit message async editMessage(req, res, next) { try { const messageId = req.params.id; if (!messageId) { throw createError.Conflict("Message id is not present"); } else { // if (!req.body.content.trim()) { // throw createError.Conflict("Cannot set empty string as content"); // } else {
0
1
0
+ 6 other calls in file
150 151 152 153 154 155 156 157 158 159
if (!id) { throw createError.Conflict("Request params is not present"); } else { const userId = req.body.userId; if (!userId) { throw createError.Conflict("User ID is not present"); } else { const data = await updateGroupMember("members", id, userId); try { return res.status(200).json({ msg: data });
0
1
0
+ 10 other calls in file
30 31 32 33 34 35 36 37 38 39
let queryAdditionalDatabase = '' let queryValueDatabase = '' let result = '' if (!bodyLength) throw new createErrors.BadRequest('Request body empty!') if (user) throw new createErrors.Conflict('Account has been registered!') const hashPassword = await argon2.hash(data.password, { type: argon2.argon2id }) const randomCode = random(12) const encryptRandomCode = legacyEncrypt(randomCode)
0
0
0
+ 5 other calls in file
GitHub: aiotrope/memento
15 16 17 18 19 20 21 22 23 24
try { const userExist = await User.findOne({ where: { username: username } }) const response = schema.signupSchema.safeParse(req.body) if (userExist) throw createError.Conflict('Cannot use the username provided!') if (!response.success) { const errorMessage = generateErrorMessage( response.error.issues, schema.options
0
0
0
12 13 14 15 16 17 18 19 20 21
const savedUser = await newUser.save(); return Promise.resolve(savedUser); } catch (error) { if( error.code && error.code == 11000 ) { error = createErrors.Conflict(`${userbody.email} already exists`); return Promise.reject(error); } return Promise.reject(error); }
0
0
0
13 14 15 16 17 18 19 20 21 22
if (error.isJoi === true) { error.status = 422; } if (error.message.includes("E11000")) { return next( createError.Conflict(`User with email ${user.email} already exists`) ); } console.log("Error at creating user in create User controller", error); next(error);
0
0
0
6 7 8 9 10 11 12 13 14 15 16 17
const register = async (req, res) => { const { email, password, subscription } = req.body; const user = await User.findOne({ email }); if (user) { throw new Conflict(`User with ${email} already exist`); } const verificationToken = nanoid(); const avatarURL = gravatar.url(email, { d: "monsterid" });
0
0
0
11 12 13 14 15 16 17 18 19 20
throw new BadRequest(error.message); } const { name, email, password } = req.body; const user = await User.findOne({ email }); if (user) { throw new Conflict('Email in use'); } const salt = await bcrypt.genSalt(10); const hashPassword = await bcrypt.hash(password, salt); const id = nanoid(16);
0
0
0
11 12 13 14 15 16 17 18 19
console.log(req.body); const { name, email, companyName, phone, password } = req.body; try { // check weather the user is already exist let isExist = await User.findOne({ email: email }); if (isExist) throw createError.Conflict("This email already in use"); // hasing the password const hash = await bcrypt.hash(password, 12);
0
0
0
http-errors.NotFound is the most popular function in http-errors (1819 examples)