arkos 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -0
- package/dist/src/app.d.ts +10 -0
- package/dist/src/app.d.ts.map +1 -0
- package/dist/src/app.js +114 -0
- package/dist/src/app.js.map +1 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +51 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/modules/auth/auth.controller.d.ts +23 -0
- package/dist/src/modules/auth/auth.controller.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.controller.js +317 -0
- package/dist/src/modules/auth/auth.controller.js.map +1 -0
- package/dist/src/modules/auth/auth.router.d.ts +4 -0
- package/dist/src/modules/auth/auth.router.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.router.js +64 -0
- package/dist/src/modules/auth/auth.router.js.map +1 -0
- package/dist/src/modules/auth/auth.service.d.ts +16 -0
- package/dist/src/modules/auth/auth.service.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.service.js +122 -0
- package/dist/src/modules/auth/auth.service.js.map +1 -0
- package/dist/src/modules/base/base.controller.d.ts +17 -0
- package/dist/src/modules/base/base.controller.d.ts.map +1 -0
- package/dist/src/modules/base/base.controller.js +296 -0
- package/dist/src/modules/base/base.controller.js.map +1 -0
- package/dist/src/modules/base/base.middlewares.d.ts +20 -0
- package/dist/src/modules/base/base.middlewares.d.ts.map +1 -0
- package/dist/src/modules/base/base.middlewares.js +86 -0
- package/dist/src/modules/base/base.middlewares.js.map +1 -0
- package/dist/src/modules/base/base.router.d.ts +4 -0
- package/dist/src/modules/base/base.router.d.ts.map +1 -0
- package/dist/src/modules/base/base.router.js +74 -0
- package/dist/src/modules/base/base.router.js.map +1 -0
- package/dist/src/modules/base/base.service.d.ts +32 -0
- package/dist/src/modules/base/base.service.d.ts.map +1 -0
- package/dist/src/modules/base/base.service.js +149 -0
- package/dist/src/modules/base/base.service.js.map +1 -0
- package/dist/src/modules/base/utils/base.helpers.d.ts +29 -0
- package/dist/src/modules/base/utils/base.helpers.d.ts.map +1 -0
- package/dist/src/modules/base/utils/base.helpers.js +106 -0
- package/dist/src/modules/base/utils/base.helpers.js.map +1 -0
- package/dist/src/modules/email/email.service.d.ts +22 -0
- package/dist/src/modules/email/email.service.d.ts.map +1 -0
- package/dist/src/modules/email/email.service.js +45 -0
- package/dist/src/modules/email/email.service.js.map +1 -0
- package/dist/src/modules/email/utils/email.helpers.d.ts +9 -0
- package/dist/src/modules/email/utils/email.helpers.d.ts.map +1 -0
- package/dist/src/modules/email/utils/email.helpers.js +25 -0
- package/dist/src/modules/email/utils/email.helpers.js.map +1 -0
- package/dist/src/modules/error-handler/error-handler.controller.d.ts +4 -0
- package/dist/src/modules/error-handler/error-handler.controller.d.ts.map +1 -0
- package/dist/src/modules/error-handler/error-handler.controller.js +182 -0
- package/dist/src/modules/error-handler/error-handler.controller.js.map +1 -0
- package/dist/src/modules/error-handler/utils/app-error.d.ts +11 -0
- package/dist/src/modules/error-handler/utils/app-error.d.ts.map +1 -0
- package/dist/src/modules/error-handler/utils/app-error.js +23 -0
- package/dist/src/modules/error-handler/utils/app-error.js.map +1 -0
- package/dist/src/modules/error-handler/utils/catch-async.d.ts +4 -0
- package/dist/src/modules/error-handler/utils/catch-async.d.ts.map +1 -0
- package/dist/src/modules/error-handler/utils/catch-async.js +9 -0
- package/dist/src/modules/error-handler/utils/catch-async.js.map +1 -0
- package/dist/src/modules/error-handler/utils/error-handler.helpers.d.ts +43 -0
- package/dist/src/modules/error-handler/utils/error-handler.helpers.d.ts.map +1 -0
- package/dist/src/modules/error-handler/utils/error-handler.helpers.js +209 -0
- package/dist/src/modules/error-handler/utils/error-handler.helpers.js.map +1 -0
- package/dist/src/modules/file-uploader/file-uploader.service.d.ts +20 -0
- package/dist/src/modules/file-uploader/file-uploader.service.d.ts.map +1 -0
- package/dist/src/modules/file-uploader/file-uploader.service.js +114 -0
- package/dist/src/modules/file-uploader/file-uploader.service.js.map +1 -0
- package/dist/src/paths.d.ts +2 -0
- package/dist/src/paths.d.ts.map +1 -0
- package/dist/src/paths.js +9 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/utils/features/api.features.d.ts +20 -0
- package/dist/src/utils/features/api.features.d.ts.map +1 -0
- package/dist/src/utils/features/api.features.js +177 -0
- package/dist/src/utils/features/api.features.js.map +1 -0
- package/dist/src/utils/features/prisma.helpers.d.ts +3 -0
- package/dist/src/utils/features/prisma.helpers.d.ts.map +1 -0
- package/dist/src/utils/features/prisma.helpers.js +20 -0
- package/dist/src/utils/features/prisma.helpers.js.map +1 -0
- package/dist/src/utils/helpers/api.features.helpers.d.ts +41 -0
- package/dist/src/utils/helpers/api.features.helpers.d.ts.map +1 -0
- package/dist/src/utils/helpers/api.features.helpers.js +161 -0
- package/dist/src/utils/helpers/api.features.helpers.js.map +1 -0
- package/dist/src/utils/helpers/models.helpers.d.ts +21 -0
- package/dist/src/utils/helpers/models.helpers.d.ts.map +1 -0
- package/dist/src/utils/helpers/models.helpers.js +195 -0
- package/dist/src/utils/helpers/models.helpers.js.map +1 -0
- package/dist/src/utils/helpers/text.helpers.d.ts +2 -0
- package/dist/src/utils/helpers/text.helpers.d.ts.map +1 -0
- package/dist/src/utils/helpers/text.helpers.js +12 -0
- package/dist/src/utils/helpers/text.helpers.js.map +1 -0
- package/dist/src/utils/permissions/index.d.ts +3 -0
- package/dist/src/utils/permissions/index.d.ts.map +1 -0
- package/dist/src/utils/permissions/index.js +17 -0
- package/dist/src/utils/permissions/index.js.map +1 -0
- package/dist/src/utils/scripts/export-prisma-types.d.ts +2 -0
- package/dist/src/utils/scripts/export-prisma-types.d.ts.map +1 -0
- package/dist/src/utils/scripts/export-prisma-types.js +152 -0
- package/dist/src/utils/scripts/export-prisma-types.js.map +1 -0
- package/dist/src/utils/scripts/generate-zod-schemas.d.ts +2 -0
- package/dist/src/utils/scripts/generate-zod-schemas.d.ts.map +1 -0
- package/dist/src/utils/scripts/generate-zod-schemas.js +121 -0
- package/dist/src/utils/scripts/generate-zod-schemas.js.map +1 -0
- package/dist/src/utils/scripts/prisma-db-push.d.ts +2 -0
- package/dist/src/utils/scripts/prisma-db-push.d.ts.map +1 -0
- package/dist/src/utils/scripts/prisma-db-push.js +24 -0
- package/dist/src/utils/scripts/prisma-db-push.js.map +1 -0
- package/dist/src/utils/validate-dto.d.ts +3 -0
- package/dist/src/utils/validate-dto.d.ts.map +1 -0
- package/dist/src/utils/validate-dto.js +17 -0
- package/dist/src/utils/validate-dto.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BaseService = void 0;
|
|
7
|
+
const change_case_all_1 = require("change-case-all");
|
|
8
|
+
const models_helpers_1 = require("../../utils/helpers/models.helpers");
|
|
9
|
+
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
10
|
+
// import { prisma } from "../../../../../src/utils/prisma";
|
|
11
|
+
const app_error_1 = __importDefault(require("../error-handler/utils/app-error"));
|
|
12
|
+
const pluralize_1 = __importDefault(require("pluralize"));
|
|
13
|
+
const base_helpers_1 = require("./utils/base.helpers");
|
|
14
|
+
const app_1 = require("../../app");
|
|
15
|
+
const baseServices = {};
|
|
16
|
+
class BaseService {
|
|
17
|
+
modelName;
|
|
18
|
+
relationFields;
|
|
19
|
+
singularRelationFieldToInclude;
|
|
20
|
+
listRelationFieldToInclude;
|
|
21
|
+
// private static instance: Singleton
|
|
22
|
+
prisma;
|
|
23
|
+
constructor(modelName) {
|
|
24
|
+
this.modelName = (0, change_case_all_1.camelCase)(modelName);
|
|
25
|
+
this.relationFields = (0, models_helpers_1.getPrismaModelRelations)((0, change_case_all_1.pascalCase)(modelName));
|
|
26
|
+
this.singularRelationFieldToInclude = this.relationFields?.singular?.reduce((acc, curr) => {
|
|
27
|
+
acc[curr.name] = true;
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
this.listRelationFieldToInclude = this.relationFields?.list?.reduce((acc, curr) => {
|
|
31
|
+
acc[curr.name] = true;
|
|
32
|
+
return acc;
|
|
33
|
+
}, {});
|
|
34
|
+
this.prisma = app_1.initConfigs.prisma;
|
|
35
|
+
}
|
|
36
|
+
async createOne(body, queryOptions) {
|
|
37
|
+
const bodyWithRelationFieldsHandled = (0, base_helpers_1.handleRelationFieldsInBody)(body, {
|
|
38
|
+
...this.relationFields,
|
|
39
|
+
}, ["delete", "disconnect", "update"]);
|
|
40
|
+
return await this.prisma[this.modelName].create((0, deepmerge_1.default)({
|
|
41
|
+
data: bodyWithRelationFieldsHandled,
|
|
42
|
+
include: {
|
|
43
|
+
...this.singularRelationFieldToInclude,
|
|
44
|
+
...this.singularRelationFieldToInclude,
|
|
45
|
+
},
|
|
46
|
+
}, JSON.parse(queryOptions || "{}")));
|
|
47
|
+
}
|
|
48
|
+
async createMany(body) {
|
|
49
|
+
if (!Array.isArray(body) || body.length === 0) {
|
|
50
|
+
throw new app_error_1.default("Invalid or empty data array provided for creation.", 400);
|
|
51
|
+
}
|
|
52
|
+
const data = await this.prisma[this.modelName].createMany({
|
|
53
|
+
data: body,
|
|
54
|
+
});
|
|
55
|
+
const total = await this.prisma[this.modelName].count();
|
|
56
|
+
return { total, data };
|
|
57
|
+
}
|
|
58
|
+
async findMany(filters) {
|
|
59
|
+
const data = await this.prisma[this.modelName].findMany("select" in filters
|
|
60
|
+
? (0, deepmerge_1.default)({ ...filters }, {
|
|
61
|
+
select: this.singularRelationFieldToInclude,
|
|
62
|
+
})
|
|
63
|
+
: (0, deepmerge_1.default)({ ...filters }, {
|
|
64
|
+
include: this.singularRelationFieldToInclude,
|
|
65
|
+
}));
|
|
66
|
+
const total = await this.prisma[this.modelName].count({
|
|
67
|
+
where: filters.where,
|
|
68
|
+
});
|
|
69
|
+
return { total, data };
|
|
70
|
+
}
|
|
71
|
+
async findOne(params, queryOptions) {
|
|
72
|
+
const data = await this.prisma[this.modelName].findUnique((0, deepmerge_1.default)({
|
|
73
|
+
where: { ...params, id: String(params.id) },
|
|
74
|
+
...(JSON.parse(queryOptions || "{}").hasOwnProperty("select")
|
|
75
|
+
? {
|
|
76
|
+
select: {
|
|
77
|
+
...this.singularRelationFieldToInclude,
|
|
78
|
+
...this.singularRelationFieldToInclude,
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
: {
|
|
82
|
+
include: {
|
|
83
|
+
...this.singularRelationFieldToInclude,
|
|
84
|
+
...this.singularRelationFieldToInclude,
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
}, JSON.parse(queryOptions || "{}")));
|
|
88
|
+
if (!data) {
|
|
89
|
+
throw new app_error_1.default(`${(0, change_case_all_1.pascalCase)(String(this.modelName))} with ID ${params.id} not found`, 404);
|
|
90
|
+
}
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
async updateOne(params, body, queryOptions) {
|
|
94
|
+
const bodyWithRelationFieldsHandled = (0, base_helpers_1.handleRelationFieldsInBody)(body, {
|
|
95
|
+
...this.relationFields,
|
|
96
|
+
});
|
|
97
|
+
const data = await this.prisma[this.modelName].update((0, deepmerge_1.default)({
|
|
98
|
+
where: { ...params, id: String(params.id) },
|
|
99
|
+
data: bodyWithRelationFieldsHandled,
|
|
100
|
+
include: {
|
|
101
|
+
...this.singularRelationFieldToInclude,
|
|
102
|
+
...this.singularRelationFieldToInclude,
|
|
103
|
+
},
|
|
104
|
+
}, JSON.parse(queryOptions || "{}")));
|
|
105
|
+
if (!data) {
|
|
106
|
+
throw new app_error_1.default(`${(0, change_case_all_1.pascalCase)(String(this.modelName))} with ID ${params.id} not found`, 404);
|
|
107
|
+
}
|
|
108
|
+
return data;
|
|
109
|
+
}
|
|
110
|
+
async updateMany(filter, body) {
|
|
111
|
+
if (!filter || typeof filter !== "object") {
|
|
112
|
+
throw new app_error_1.default("Invalid filter provided for udpate many.", 400);
|
|
113
|
+
}
|
|
114
|
+
const data = await this.prisma[this.modelName].updateMany({
|
|
115
|
+
...filter,
|
|
116
|
+
data: body,
|
|
117
|
+
});
|
|
118
|
+
if (!data || data.count === 0) {
|
|
119
|
+
throw new app_error_1.default(`${(0, pluralize_1.default)((0, change_case_all_1.pascalCase)(String(this.modelName)))} not found`, 404);
|
|
120
|
+
}
|
|
121
|
+
const total = await this.prisma[this.modelName].count();
|
|
122
|
+
return { total, data };
|
|
123
|
+
}
|
|
124
|
+
async deleteOne(params) {
|
|
125
|
+
return await this.prisma[this.modelName].delete({
|
|
126
|
+
where: {
|
|
127
|
+
...params,
|
|
128
|
+
id: String(params.id),
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
async deleteMany(filter) {
|
|
133
|
+
if (!filter || typeof filter !== "object") {
|
|
134
|
+
throw new app_error_1.default("Invalid filter provided for deletion.", 400);
|
|
135
|
+
}
|
|
136
|
+
const data = await this.prisma[this.modelName].deleteMany(filter);
|
|
137
|
+
if (!data || data.count === 0) {
|
|
138
|
+
throw new app_error_1.default(`No records found to delete`, 404);
|
|
139
|
+
}
|
|
140
|
+
const total = await this.prisma[this.modelName].count();
|
|
141
|
+
return { total, data };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.BaseService = BaseService;
|
|
145
|
+
models_helpers_1.models.forEach((model) => {
|
|
146
|
+
baseServices[`${(0, change_case_all_1.camelCase)(model)}`] = new BaseService(model);
|
|
147
|
+
});
|
|
148
|
+
exports.default = baseServices;
|
|
149
|
+
//# sourceMappingURL=base.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.service.js","sourceRoot":"","sources":["../../../../src/modules/base/base.service.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAwD;AACxD,uEAI4C;AAC5C,0DAA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0 +1,29 @@
|
|
|
1
|
+
import { RelationFields } from "../../../utils/helpers/models.helpers";
|
|
2
|
+
/**
|
|
3
|
+
* Determines the appropriate Prisma operation (`create`, `connect`, `update`, `delete`, or `disconnect`)
|
|
4
|
+
* for each relation field in the provided body based on its nested data and recursively does the same for each relation field.
|
|
5
|
+
*
|
|
6
|
+
* This function handles the following types of relations:
|
|
7
|
+
* - **One-to-one**
|
|
8
|
+
* - **One-to-many**
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* ### Operation Rules:
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* - **Create**: Used when the nested relation data is provided **without an `id`**.
|
|
15
|
+
* - **Connect**: Used when the nested relation data contains **only an `id`**.
|
|
16
|
+
* - **Update**: Used when the nested relation data contains **both an `id` and additional fields**.
|
|
17
|
+
* - **Delete**: Used when the nested relation data includes **`apiAction: "delete"`**.
|
|
18
|
+
* - **Disconnect**: Used when the nested relation data includes **`apiAction: "disconnect"`**.
|
|
19
|
+
*
|
|
20
|
+
* @param {Record<string, any>} body - The object containing relation fields to be processed.
|
|
21
|
+
* @param {Object} relationFields - Defines relation field types.
|
|
22
|
+
* @param {RelationFields[]} relationFields.singular - List of one-side relation field names (one-to-one).
|
|
23
|
+
* @param {RelationFields[]} relationFields.list - List of many-side relation field names (one-to-many).
|
|
24
|
+
* @returns {T} The transformed data with appropriate Prisma operations applied.
|
|
25
|
+
*/
|
|
26
|
+
export declare function handleRelationFieldsInBody(body: Record<string, any>, relationFields: RelationFields, ignoreActions?: string[]): {
|
|
27
|
+
[x: string]: any;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=base.helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.helpers.d.ts","sourceRoot":"","sources":["../../../../../src/modules/base/utils/base.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACf,MAAM,uCAAuC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,cAAc,EAAE,cAAc,EAC9B,aAAa,GAAE,MAAM,EAAO;;EA0F7B"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleRelationFieldsInBody = handleRelationFieldsInBody;
|
|
4
|
+
const models_helpers_1 = require("../../../utils/helpers/models.helpers");
|
|
5
|
+
/**
|
|
6
|
+
* Determines the appropriate Prisma operation (`create`, `connect`, `update`, `delete`, or `disconnect`)
|
|
7
|
+
* for each relation field in the provided body based on its nested data and recursively does the same for each relation field.
|
|
8
|
+
*
|
|
9
|
+
* This function handles the following types of relations:
|
|
10
|
+
* - **One-to-one**
|
|
11
|
+
* - **One-to-many**
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* ### Operation Rules:
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* - **Create**: Used when the nested relation data is provided **without an `id`**.
|
|
18
|
+
* - **Connect**: Used when the nested relation data contains **only an `id`**.
|
|
19
|
+
* - **Update**: Used when the nested relation data contains **both an `id` and additional fields**.
|
|
20
|
+
* - **Delete**: Used when the nested relation data includes **`apiAction: "delete"`**.
|
|
21
|
+
* - **Disconnect**: Used when the nested relation data includes **`apiAction: "disconnect"`**.
|
|
22
|
+
*
|
|
23
|
+
* @param {Record<string, any>} body - The object containing relation fields to be processed.
|
|
24
|
+
* @param {Object} relationFields - Defines relation field types.
|
|
25
|
+
* @param {RelationFields[]} relationFields.singular - List of one-side relation field names (one-to-one).
|
|
26
|
+
* @param {RelationFields[]} relationFields.list - List of many-side relation field names (one-to-many).
|
|
27
|
+
* @returns {T} The transformed data with appropriate Prisma operations applied.
|
|
28
|
+
*/
|
|
29
|
+
function handleRelationFieldsInBody(body, relationFields, ignoreActions = []) {
|
|
30
|
+
let mutableBody = { ...body };
|
|
31
|
+
relationFields.list.forEach((field) => {
|
|
32
|
+
if (!body[field.name])
|
|
33
|
+
return;
|
|
34
|
+
const createData = [];
|
|
35
|
+
const connectData = [];
|
|
36
|
+
const updateData = [];
|
|
37
|
+
const disconnectData = [];
|
|
38
|
+
const deleteManyIds = [];
|
|
39
|
+
body[field.name].forEach((bodyField) => {
|
|
40
|
+
if (ignoreActions.includes(bodyField?.apiAction))
|
|
41
|
+
return;
|
|
42
|
+
if (bodyField?.apiAction === "delete") {
|
|
43
|
+
deleteManyIds.push(bodyField.id);
|
|
44
|
+
}
|
|
45
|
+
else if (bodyField?.apiAction === "disconnect") {
|
|
46
|
+
disconnectData.push({ id: bodyField.id });
|
|
47
|
+
}
|
|
48
|
+
else if (!bodyField?.id) {
|
|
49
|
+
let nestedRelations = (0, models_helpers_1.getPrismaModelRelations)(field.type);
|
|
50
|
+
const dataToPush = nestedRelations
|
|
51
|
+
? handleRelationFieldsInBody(bodyField, nestedRelations, ignoreActions)
|
|
52
|
+
: bodyField;
|
|
53
|
+
createData.push(dataToPush);
|
|
54
|
+
}
|
|
55
|
+
else if (Object.keys(bodyField).length === 1) {
|
|
56
|
+
connectData.push(bodyField);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const { id, ...data } = bodyField;
|
|
60
|
+
let nestedRelations = (0, models_helpers_1.getPrismaModelRelations)(field.type);
|
|
61
|
+
const dataToPush = nestedRelations
|
|
62
|
+
? handleRelationFieldsInBody(data, nestedRelations, ignoreActions)
|
|
63
|
+
: bodyField;
|
|
64
|
+
updateData.push({
|
|
65
|
+
where: { id },
|
|
66
|
+
data: dataToPush,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
mutableBody[field.name] = {
|
|
71
|
+
...(createData.length ? { create: createData } : {}),
|
|
72
|
+
...(connectData.length ? { connect: connectData } : {}),
|
|
73
|
+
...(updateData.length ? { update: updateData } : {}),
|
|
74
|
+
...(disconnectData.length ? { disconnect: disconnectData } : {}),
|
|
75
|
+
...(deleteManyIds.length
|
|
76
|
+
? { deleteMany: { id: { in: deleteManyIds } } }
|
|
77
|
+
: {}),
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
relationFields.singular.forEach((field) => {
|
|
81
|
+
if (!body[field.name])
|
|
82
|
+
return;
|
|
83
|
+
if (ignoreActions.includes(body[field.name]?.apiAction))
|
|
84
|
+
return;
|
|
85
|
+
let nestedRelations = (0, models_helpers_1.getPrismaModelRelations)(field.type);
|
|
86
|
+
if (!body[field.name]?.id) {
|
|
87
|
+
mutableBody[field.name] = {
|
|
88
|
+
create: handleRelationFieldsInBody(body[field.name], nestedRelations, ignoreActions),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
else if (Object.keys(body[field.name]).length === 1) {
|
|
92
|
+
mutableBody[field.name] = { connect: body[field.name] };
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const { id, ...data } = body[field.name];
|
|
96
|
+
mutableBody[field.name] = {
|
|
97
|
+
update: {
|
|
98
|
+
where: { id },
|
|
99
|
+
data: handleRelationFieldsInBody(data, nestedRelations, ignoreActions),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return mutableBody;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=base.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.helpers.js","sourceRoot":"","sources":["../../../../../src/modules/base/utils/base.helpers.ts"],"names":[],"mappings":";;AA6BA,gEA6FC;AA1HD,0EAG+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,0BAA0B,CACxC,IAAyB,EACzB,cAA8B,EAC9B,gBAA0B,EAAE;IAE5B,IAAI,WAAW,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAE9B,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;Q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,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;YAAE,OAAO;QAEhE,IAAI,eAAe,GAAG,IAAA,wCAAuB,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE1D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;YAC1B,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG;gBACxB,MAAM,EAAE,0BAA0B,CAChC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAChB,eAAgB,EAChB,aAAa,CACd;aACF,CAAC;QACJ,CAAC;aAAM,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtD,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG;gBACxB,MAAM,EAAE;oBACN,KAAK,EAAE,EAAE,EAAE,EAAE;oBACb,IAAI,EAAE,0BAA0B,CAC9B,IAAI,EACJ,eAAgB,EAChB,aAAa,CACd;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseService } from '../base/base.service';
|
|
2
|
+
export type EmailOptions = {
|
|
3
|
+
from?: string;
|
|
4
|
+
to: string | string[];
|
|
5
|
+
subject: string;
|
|
6
|
+
text?: string;
|
|
7
|
+
html?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class EmailService extends BaseService {
|
|
10
|
+
private transporter;
|
|
11
|
+
constructor(host?: string, auth?: {
|
|
12
|
+
user: string | undefined;
|
|
13
|
+
pass: string | undefined;
|
|
14
|
+
}, port?: number);
|
|
15
|
+
private verifyConnection;
|
|
16
|
+
send(options: EmailOptions): Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
messageId?: string;
|
|
19
|
+
error?: any;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=email.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.service.d.ts","sourceRoot":"","sources":["../../../../src/modules/email/email.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,qBAAa,YAAa,SAAQ,WAAW;IAC3C,OAAO,CAAC,WAAW,CAAa;gBAG9B,IAAI,GAAE,MAAgC,EACtC,IAAI;;;KAAqE,EACzE,IAAI,SAA4C;IAWlD,OAAO,CAAC,gBAAgB;IAUX,IAAI,CACf,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;CAclE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EmailService = void 0;
|
|
7
|
+
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
8
|
+
const base_service_1 = require("../base/base.service");
|
|
9
|
+
class EmailService extends base_service_1.BaseService {
|
|
10
|
+
transporter;
|
|
11
|
+
constructor(host = process.env.EMAIL_HOST, auth = { user: process.env.EMAIL_FROM, pass: process.env.EMAIL_PASSWORD }, port = parseInt(process.env.EMAIL_PORT || '465')) {
|
|
12
|
+
super('email');
|
|
13
|
+
this.transporter = nodemailer_1.default.createTransport({
|
|
14
|
+
host,
|
|
15
|
+
port,
|
|
16
|
+
secure: true,
|
|
17
|
+
auth,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
verifyConnection() {
|
|
21
|
+
this.transporter.verify((error) => {
|
|
22
|
+
if (error) {
|
|
23
|
+
console.error('Email server connection error:', error);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
console.info('Email server connection successful');
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async send(options) {
|
|
31
|
+
try {
|
|
32
|
+
this.verifyConnection();
|
|
33
|
+
const info = await this.transporter.sendMail({
|
|
34
|
+
...options,
|
|
35
|
+
from: options?.from || process.env.EMAIL_FROM,
|
|
36
|
+
});
|
|
37
|
+
return { success: true, messageId: info.messageId };
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.EmailService = EmailService;
|
|
45
|
+
//# sourceMappingURL=email.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.service.js","sourceRoot":"","sources":["../../../../src/modules/email/email.service.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoD;AACpD,uDAAkD;AAUlD,MAAa,YAAa,SAAQ,0BAAW;IACnC,WAAW,CAAa;IAEhC,YACE,OAAe,OAAO,CAAC,GAAG,CAAC,UAAW,EACtC,IAAI,GAAG,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
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export declare const generateToken: (payload: TokenPayload) => string;
|
|
7
|
+
export declare const verifyToken: (token: string) => TokenPayload | null;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=email.helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.helpers.d.ts","sourceRoot":"","sources":["../../../../../src/modules/email/utils/email.helpers.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,GAAI,SAAS,YAAY,KAAG,MAKrD,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,YAAY,GAAG,IAQ1D,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.verifyToken = exports.generateToken = void 0;
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
const generateToken = (payload) => {
|
|
9
|
+
const secret = process.env.JWT_SECRET || "your-default-secret";
|
|
10
|
+
const expiresIn = process.env.TOKEN_EXPIRY || "24h";
|
|
11
|
+
return jsonwebtoken_1.default.sign(payload, secret, { expiresIn: expiresIn });
|
|
12
|
+
};
|
|
13
|
+
exports.generateToken = generateToken;
|
|
14
|
+
const verifyToken = (token) => {
|
|
15
|
+
try {
|
|
16
|
+
const secret = process.env.JWT_SECRET || "your-default-secret";
|
|
17
|
+
return jsonwebtoken_1.default.verify(token, secret);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error("Token verification failed:", error);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.verifyToken = verifyToken;
|
|
25
|
+
//# sourceMappingURL=email.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.helpers.js","sourceRoot":"","sources":["../../../../../src/modules/email/utils/email.helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAA+B;AAQxB,MAAM,aAAa,GAAG,CAAC,OAAqB,EAAU,EAAE;IAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,qBAAqB,CAAC;IAC/D,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,KAAK,CAAC;IAEpD,OAAO,sBAAG,CAAC,IAAI,CAAC,OAAO,EAAE,MAAa,EAAE,EAAE,SAAS,EAAE,SAAgB,EAAE,CAAC,CAAC;AAC3E,CAAC,CAAC;AALW,QAAA,aAAa,iBAKxB;AAEK,MAAM,WAAW,GAAG,CAAC,KAAa,EAAuB,EAAE;IAChE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,qBAAqB,CAAC;QAC/D,OAAO,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAiB,CAAC;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AARW,QAAA,WAAW,eAQtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.controller.d.ts","sourceRoot":"","sources":["../../../../src/modules/error-handler/error-handler.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AA0EzC,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,QA0FnB"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.default = errorHandler;
|
|
37
|
+
const errorControllerHelper = __importStar(require("./utils/error-handler.helpers"));
|
|
38
|
+
const __1 = require("../..");
|
|
39
|
+
// const handleCastErrorDB = (err:) => {
|
|
40
|
+
// const message = `Invalid ${err.path}: ${err.value}`
|
|
41
|
+
// return new AppError(message, 400)
|
|
42
|
+
// }
|
|
43
|
+
// const handleDuplicateFieldDB = (err) => {
|
|
44
|
+
// const value = err.keyValue.name
|
|
45
|
+
// const message = `Duplicate fiedl value: ${value}. Please use another value!`
|
|
46
|
+
// return new AppError(message, 400)
|
|
47
|
+
// }
|
|
48
|
+
// const handleValidationErrorDB = (err) => {
|
|
49
|
+
// const errors = Object.values(err.errors).map((el) => el.message)
|
|
50
|
+
// const message = `Ivalid input data. ${errors.join('. ')}`
|
|
51
|
+
// return new AppError(message, 400)
|
|
52
|
+
// }
|
|
53
|
+
// const handleJWTError() =>
|
|
54
|
+
// new AppError('Invalid token. Please log in again!', 401)
|
|
55
|
+
// const handleJWTExpired = () =>
|
|
56
|
+
// new AppError('Your token has expired, Please log again!', 401)
|
|
57
|
+
function sendDevelopmentError(err, req, res) {
|
|
58
|
+
console.error("[\x1b[31mERROR\x1b[0m]:", err);
|
|
59
|
+
if (req.originalUrl.startsWith("/api"))
|
|
60
|
+
return res.status(err.statusCode).json({
|
|
61
|
+
message: err.message.split("\n")[err.message.split("\n").length - 1],
|
|
62
|
+
error: err,
|
|
63
|
+
stack: err.stack?.split("\n"),
|
|
64
|
+
});
|
|
65
|
+
res.status(err.statusCode).json({
|
|
66
|
+
title: "Something went wrong!",
|
|
67
|
+
message: err.message,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function sendProductionError(err, req, res) {
|
|
71
|
+
if (req.originalUrl.startsWith("/api")) {
|
|
72
|
+
if (err.isOperational) {
|
|
73
|
+
return res.status(err.statusCode).json({
|
|
74
|
+
status: err.status,
|
|
75
|
+
message: err.message,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
console.error("[\x1b[31mERROR\x1b[0m]:", err);
|
|
79
|
+
return res.status(500).json({
|
|
80
|
+
status: "error",
|
|
81
|
+
message: "Something went wrong!",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (err.isOperational) {
|
|
85
|
+
return res.status(err.statusCode).json({
|
|
86
|
+
title: "Something Went Wrong!",
|
|
87
|
+
message: err.message,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
console.error("[\x1b[31mERROR\x1b[0m]:", err);
|
|
91
|
+
return res.status(err.statusCode).json({
|
|
92
|
+
title: "Something went wrong!",
|
|
93
|
+
message: "Please try again later.",
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function errorHandler(err, req, res, next) {
|
|
97
|
+
err.statusCode = err.statusCode || 500;
|
|
98
|
+
err.status = err.status || "error";
|
|
99
|
+
if (process.env.NODE_ENV !== "production")
|
|
100
|
+
return sendDevelopmentError(err, req, res);
|
|
101
|
+
let error = { ...err, message: err.message };
|
|
102
|
+
if (err.name === "JsonWebTokenError")
|
|
103
|
+
error = errorControllerHelper.handleJWTError();
|
|
104
|
+
if (err.name === "TokenExpiredError")
|
|
105
|
+
error = errorControllerHelper.handleJWTExpired();
|
|
106
|
+
if (err.name === "PrismaClientValidationError")
|
|
107
|
+
error = errorControllerHelper.handlePrismaClientValidationError(err);
|
|
108
|
+
if (err.code === "P1000")
|
|
109
|
+
error = errorControllerHelper.handleAuthenticationError(err);
|
|
110
|
+
if (err.code === "P1001")
|
|
111
|
+
error = errorControllerHelper.handleServerNotReachableError(err);
|
|
112
|
+
if (err.code === "P1002")
|
|
113
|
+
error = errorControllerHelper.handleConnectionTimeoutError(err);
|
|
114
|
+
if (err.code === "P1003")
|
|
115
|
+
error = errorControllerHelper.handleDatabaseNotFoundError(err);
|
|
116
|
+
if (err.name === "EnvironmentVariableError")
|
|
117
|
+
error = errorControllerHelper.handleEnvironmentVariableError(err);
|
|
118
|
+
if (err.code === "P2000")
|
|
119
|
+
error = errorControllerHelper.handleFieldValueTooLargeError(err);
|
|
120
|
+
if (err.code === "P2001")
|
|
121
|
+
error = errorControllerHelper.handleRecordNotFoundError(err);
|
|
122
|
+
if (err.code === "P2002")
|
|
123
|
+
error = errorControllerHelper.handleUniqueConstraintError(err);
|
|
124
|
+
if (err.code === "P2003")
|
|
125
|
+
error = errorControllerHelper.handleForeignKeyConstraintError(err);
|
|
126
|
+
if (err.code === "P2004")
|
|
127
|
+
error = errorControllerHelper.handleConstraintFailedError(err);
|
|
128
|
+
if (err.code === "P2005")
|
|
129
|
+
error = errorControllerHelper.handleInvalidFieldValueError(err);
|
|
130
|
+
if (err.code === "P2006")
|
|
131
|
+
error = errorControllerHelper.handleInvalidFieldProvidedError(err);
|
|
132
|
+
if (err.code === "P2007")
|
|
133
|
+
error = errorControllerHelper.handleDataValidationError(err);
|
|
134
|
+
if (err.code === "P2008")
|
|
135
|
+
error = errorControllerHelper.handleQueryParsingError(err);
|
|
136
|
+
if (err.code === "P2009")
|
|
137
|
+
error = errorControllerHelper.handleInvalidQueryFormatError(err);
|
|
138
|
+
if (err.code === "P2010")
|
|
139
|
+
error = errorControllerHelper.handleRawQueryExecutionError(err);
|
|
140
|
+
if (err.code === "P2011")
|
|
141
|
+
error = errorControllerHelper.handleNullConstraintViolationError(err);
|
|
142
|
+
if (err.code === "P3000")
|
|
143
|
+
error = errorControllerHelper.handleSchemaCreationFailedError(err);
|
|
144
|
+
if (err.code === "P3001")
|
|
145
|
+
error = errorControllerHelper.handleMigrationAlreadyAppliedError(err);
|
|
146
|
+
if (err.code === "P3002")
|
|
147
|
+
error = errorControllerHelper.handleMigrationScriptFailedError(err);
|
|
148
|
+
if (err.code === "P3003")
|
|
149
|
+
error = errorControllerHelper.handleVersionMismatchError(err);
|
|
150
|
+
if (err.code === "P3004")
|
|
151
|
+
error = errorControllerHelper.handleMigrationFileReadError(err);
|
|
152
|
+
if (err.code === "P3005")
|
|
153
|
+
error = errorControllerHelper.handleSchemaDriftError(err);
|
|
154
|
+
if (err.name === "SyntaxError")
|
|
155
|
+
error = errorControllerHelper.handleSchemaSyntaxError(err);
|
|
156
|
+
if (err.name === "TypeError")
|
|
157
|
+
error = errorControllerHelper.handleClientTypeError(err);
|
|
158
|
+
if (err.name === "DynamicQueryError")
|
|
159
|
+
error = errorControllerHelper.handleDynamicQueryError(err);
|
|
160
|
+
if (err.name === "RelationError")
|
|
161
|
+
error = errorControllerHelper.handleRelationLoadingError(err);
|
|
162
|
+
if (err.name === "BinaryError")
|
|
163
|
+
error = errorControllerHelper.handleBinaryError(err);
|
|
164
|
+
if (err.name === "NetworkError")
|
|
165
|
+
error = errorControllerHelper.handleNetworkError(err);
|
|
166
|
+
if (err.name === "VersionMismatch")
|
|
167
|
+
error = errorControllerHelper.handleVersionMismatchError(err);
|
|
168
|
+
if (err.name === "UnhandledPromiseRejection")
|
|
169
|
+
error = errorControllerHelper.handleUnhandledPromiseError(err);
|
|
170
|
+
if (err.name === "DataTypeError")
|
|
171
|
+
error = errorControllerHelper.handleDataTypeError(err);
|
|
172
|
+
if (err.name === "EmptyResultError")
|
|
173
|
+
error = errorControllerHelper.handleEmptyResultError(err);
|
|
174
|
+
sendProductionError(error, req, res);
|
|
175
|
+
}
|
|
176
|
+
process.on("SIGTERM", () => {
|
|
177
|
+
console.error("👋🏽 SIGTERM RECEIVED. Shutting down gracefully!");
|
|
178
|
+
__1.server.close(() => {
|
|
179
|
+
console.error("🔥 Process terminated");
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
//# sourceMappingURL=error-handler.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.controller.js","sourceRoot":"","sources":["../../../../src/modules/error-handler/error-handler.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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AG,CAAC,CAAC;IACzD,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB;QACjC,KAAK,GAAG,qBAAqB,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAE5D,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAClE,UAAM,CAAC,KAAK,CAAC,GAAG,EAAE;QAChB,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class AppError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
status: string;
|
|
4
|
+
missing?: boolean;
|
|
5
|
+
isOperational: boolean;
|
|
6
|
+
code?: string;
|
|
7
|
+
meta?: Record<string, any>;
|
|
8
|
+
constructor(message: string, statusCode: number, meta?: Record<string, any>, code?: string);
|
|
9
|
+
}
|
|
10
|
+
export default AppError;
|
|
11
|
+
//# sourceMappingURL=app-error.d.ts.map
|