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