updated roles, only superAdmin can create an admin

This commit is contained in:
2025-04-23 16:29:33 +05:30
parent 804066c97a
commit 38014f7138
5 changed files with 132 additions and 160 deletions

View File

@@ -1,5 +1,5 @@
import { FastifyReply, FastifyRequest } from "fastify";
import mongoose from "mongoose";
import { FastifyReply, FastifyRequest } from 'fastify';
import mongoose from 'mongoose';
export function errorHandler(
error: any,
@@ -12,7 +12,7 @@ export function errorHandler(
if (error.validation) {
const errMsg = {
type: "validation_error",
type: 'validation_error',
path: error.validation[0].instancePath,
context: error.validationContext,
msg: error.validation[0].message,
@@ -25,9 +25,9 @@ export function errorHandler(
if (error instanceof mongoose.mongo.MongoServerError) {
if (error.code === 11000) {
return res.code(400).send({
type: "duplicate_key",
context: "body",
msg: "value already exists",
type: 'duplicate_key',
context: 'body',
msg: 'value already exists',
params: error.keyValue,
});
}