dasdasdasdasda
This commit is contained in:
@@ -30,7 +30,7 @@ export default class ServerApplication {
|
||||
}
|
||||
|
||||
async serverConfiguration() {
|
||||
// this.#APP.use(secureApp);
|
||||
this.#APP.use(secureApp);
|
||||
this.#APP.use(express.json());
|
||||
this.#APP.use(express.urlencoded({ extended: true }));
|
||||
this.#APP.set("json spaces", 2);
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Router } from 'express';
|
||||
import AuthRouter from '../../modules/auth/router/auth.routes';
|
||||
import formRouter from '../../modules/forms/index.routes';
|
||||
import userRouter from '../../modules/user/routes/user.routes';
|
||||
import CenterRouter from '../../modules/forms/center/routes/center.routes';
|
||||
|
||||
const mainRouter = Router();
|
||||
|
||||
@@ -9,4 +10,5 @@ const mainRouter = Router();
|
||||
mainRouter.use('/auth',AuthRouter)
|
||||
mainRouter.use('/user',userRouter)
|
||||
mainRouter.use('/form',formRouter)
|
||||
mainRouter.use('/center',CenterRouter)
|
||||
export default mainRouter;
|
||||
@@ -22,8 +22,10 @@ export interface IdentityAttributes {
|
||||
updatedAt?: Date;
|
||||
}
|
||||
|
||||
export interface IdentityCreationAttributes
|
||||
extends Optional<IdentityAttributes, "id" | "profilePhotoId"> {}
|
||||
export interface IdentityCreationAttributes extends Optional<
|
||||
IdentityAttributes,
|
||||
"id" | "profilePhotoId"
|
||||
> {}
|
||||
|
||||
export class Identity
|
||||
extends Model<IdentityAttributes, IdentityCreationAttributes>
|
||||
@@ -55,63 +57,64 @@ export class Identity
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true
|
||||
primaryKey: true,
|
||||
},
|
||||
|
||||
applicantId: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: false
|
||||
allowNull: false,
|
||||
},
|
||||
|
||||
firstName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
allowNull: false,
|
||||
},
|
||||
|
||||
lastName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
allowNull: false,
|
||||
},
|
||||
|
||||
fatherName: {
|
||||
type: DataTypes.STRING
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
|
||||
nationalCode: {
|
||||
type: DataTypes.STRING(10),
|
||||
allowNull: false
|
||||
allowNull: false,
|
||||
},
|
||||
|
||||
birthDate: {
|
||||
type: DataTypes.DATEONLY
|
||||
type: DataTypes.DATEONLY,
|
||||
},
|
||||
|
||||
birthPlace: {
|
||||
type: DataTypes.STRING
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
|
||||
gender: {
|
||||
type: DataTypes.STRING
|
||||
type: DataTypes.ENUM("male", "female", "other"),
|
||||
allowNull: true,
|
||||
},
|
||||
|
||||
religion: {
|
||||
type: DataTypes.STRING
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
|
||||
nationality: {
|
||||
type: DataTypes.STRING
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
|
||||
profilePhotoId: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true
|
||||
}
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: "identities",
|
||||
timestamps: true
|
||||
}
|
||||
timestamps: true,
|
||||
},
|
||||
);
|
||||
|
||||
return Identity;
|
||||
|
||||
@@ -48,7 +48,7 @@ class AuthControllerClass extends Controller {
|
||||
return res.status(200).json({
|
||||
status: 200,
|
||||
data,
|
||||
message: "با موفقيت وارد شديد",
|
||||
message: "Ok",
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
|
||||
@@ -57,24 +57,24 @@ class AuthServiceClass extends Controller {
|
||||
],
|
||||
});
|
||||
|
||||
if (!identity?.applicantId) {
|
||||
throw new createHttpError.NotFound(
|
||||
authErrorMessages.notFound.applicant,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const token = jwt.sign(
|
||||
{ userId: identity.applicantId },
|
||||
{ userId: identity?.applicantId },
|
||||
process.env.JWT_SECRET || "secret",
|
||||
{ expiresIn: "24h" }, // طول عمر توکن
|
||||
);
|
||||
|
||||
return {
|
||||
token,
|
||||
applicant: { id: identity.applicantId, fullname: `${identity.firstName} ${identity.lastName}`, role: identity },
|
||||
applicant: {
|
||||
id: identity?.applicantId,
|
||||
fullname: `${identity?.firstName} ${identity?.lastName}`,
|
||||
role: identity,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
throw new createHttpError.InternalServerError("خطای سرور");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import CenterController from "../controller/center.controller";
|
||||
const CenterRouter = Router();
|
||||
|
||||
CenterRouter.post("/", CenterController.create); // ایجاد
|
||||
CenterRouter.get("/", CenterController.getAll); // لیست همه
|
||||
CenterRouter.get("/:id", CenterController.getById); // مشاهده یکی
|
||||
CenterRouter.put("/:id", CenterController.update); // ویرایش
|
||||
CenterRouter.delete("/:id", CenterController.delete); // حذف
|
||||
CenterRouter.get("/all", CenterController.getAll); // لیست همه
|
||||
CenterRouter.get("/get/:id", CenterController.getById); // مشاهده یکی
|
||||
CenterRouter.put("/update/:id", CenterController.update); // ویرایش
|
||||
CenterRouter.delete("/delete/:id", CenterController.delete); // حذف
|
||||
|
||||
export default CenterRouter;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import createHttpError from "http-errors";
|
||||
import { Controller } from "../../../../core/controller/main.controller";
|
||||
import { GlobalErrorMessages } from "../../../../core/messages/errors";
|
||||
import { Center } from "../../../../models/Center";
|
||||
import { JobCategory } from "../../../../models/JobCategory";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user