Spaces:
Running
Running
File size: 1,092 Bytes
5a6eb7f 2003362 5a6eb7f a6fbb8d 5a6eb7f a6fbb8d 5a6eb7f a6fbb8d 5a6eb7f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import { jwtHelper } from "../../../../helpers/jwt.helper";
import { validator } from "../../../../helpers/validation.helper";
import { BaseController } from "../../../../lib/controllers/controller.base";
import { Prefix } from "../../../common/decorators/prefix.decorator";
import { usersService } from "../services/users.service";
import { adminUserValidation } from "../validation/admin.userValidation";
const allowedRoles = ["superAdmin", "admin"];
@Prefix("/admin/users")
export class adminUsersController extends BaseController {
static setRoutes(router) {
router.post(
"/create",
jwtHelper.verifyToken(allowedRoles),
validator(adminUserValidation.createValidation),
adminUsersController.create
);
}
static async create(req, res) {
try {
let result = await usersService.create(req.body);
return res.status(result.code).json(result);
} catch (err) {
console.log(`err.message`, err.message);
return res.status(500).json({
success: false,
code: 500,
error: err.message,
});
}
}
}
|