@drax/crud-back 0.51.0 → 1.1.0
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/dist/builders/CrudSchemaBuilder.js +20 -21
- package/dist/controllers/AbstractFastifyController.js +16 -0
- package/package.json +7 -8
- package/src/builders/CrudSchemaBuilder.ts +21 -22
- package/src/controllers/AbstractFastifyController.ts +25 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/types/builders/CrudSchemaBuilder.d.ts +1001 -1154
- package/types/builders/CrudSchemaBuilder.d.ts.map +1 -1
- package/types/controllers/AbstractFastifyController.d.ts +4 -0
- package/types/controllers/AbstractFastifyController.d.ts.map +1 -1
- package/types/schemas/DeleteBodyResponseSchema.d.ts +1 -11
- package/types/schemas/DeleteBodyResponseSchema.d.ts.map +1 -1
- package/types/schemas/ErrorBodyResponseSchema.d.ts +3 -60
- package/types/schemas/ErrorBodyResponseSchema.d.ts.map +1 -1
- package/types/schemas/ExportBodyResponseSchema.d.ts +1 -11
- package/types/schemas/ExportBodyResponseSchema.d.ts.map +1 -1
- package/types/schemas/FindBySchema.d.ts +1 -7
- package/types/schemas/FindBySchema.d.ts.map +1 -1
- package/types/schemas/FindSchema.d.ts +5 -12
- package/types/schemas/FindSchema.d.ts.map +1 -1
- package/types/schemas/GroupBySchema.d.ts +2 -8
- package/types/schemas/GroupBySchema.d.ts.map +1 -1
- package/types/schemas/IdParamSchema.d.ts +1 -5
- package/types/schemas/IdParamSchema.d.ts.map +1 -1
- package/types/schemas/PaginateSchema.d.ts +7 -28
- package/types/schemas/PaginateSchema.d.ts.map +1 -1
- package/types/schemas/SearchSchema.d.ts +1 -5
- package/types/schemas/SearchSchema.d.ts.map +1 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
2
|
import { IdParamSchema, DeleteBodyResponseSchema, PaginateQuerySchema, PaginateBodyResponseSchema, FindQuerySchema, SearchQuerySchema, FindByParamSchema, ErrorBodyResponseSchema, ValidationErrorBodyResponseSchema, ExportBodyResponseSchema, GroupByQuerySchema } from '../index.js';
|
|
4
3
|
export class CrudSchemaBuilder {
|
|
5
|
-
constructor(entitySchema, entityCreateSchema, entityUpdateSchema, entityName, target = '
|
|
6
|
-
this.target = '
|
|
4
|
+
constructor(entitySchema, entityCreateSchema, entityUpdateSchema, entityName, target = 'openapi-3.0', tags = []) {
|
|
5
|
+
this.target = 'openapi-3.0'; //"jsonSchema7" | "jsonSchema2019-09" | "openapi-3.0" | "openAi"
|
|
7
6
|
this.entitySchema = entitySchema;
|
|
8
7
|
this.entityCreateSchema = entityCreateSchema;
|
|
9
8
|
this.entityUpdateSchema = entityUpdateSchema;
|
|
@@ -18,56 +17,56 @@ export class CrudSchemaBuilder {
|
|
|
18
17
|
return [];
|
|
19
18
|
}
|
|
20
19
|
get jsonEntityCreateSchema() {
|
|
21
|
-
return
|
|
20
|
+
return z.toJSONSchema(this.entityCreateSchema, { target: this.target });
|
|
22
21
|
}
|
|
23
22
|
get jsonEntityUpdateSchema() {
|
|
24
|
-
return
|
|
23
|
+
return z.toJSONSchema(this.entityUpdateSchema, { target: this.target });
|
|
25
24
|
}
|
|
26
25
|
get jsonEntitySchema() {
|
|
27
|
-
return
|
|
26
|
+
return z.toJSONSchema(this.entitySchema, { target: this.target });
|
|
28
27
|
}
|
|
29
28
|
get jsonEntityArraySchema() {
|
|
30
|
-
return
|
|
29
|
+
return z.toJSONSchema(z.array(this.entitySchema), { target: this.target });
|
|
31
30
|
}
|
|
32
31
|
get jsonEntityGroupBySchema() {
|
|
33
|
-
return
|
|
32
|
+
return z.toJSONSchema(z.array(z.object({
|
|
34
33
|
count: z.number()
|
|
35
34
|
}).catchall(z.any())), { target: this.target });
|
|
36
35
|
}
|
|
37
36
|
get jsonExportBodyResponse() {
|
|
38
|
-
return
|
|
37
|
+
return z.toJSONSchema(ExportBodyResponseSchema, { target: this.target });
|
|
39
38
|
}
|
|
40
39
|
get jsonErrorBodyResponse() {
|
|
41
|
-
return
|
|
40
|
+
return z.toJSONSchema(ErrorBodyResponseSchema, { target: this.target });
|
|
42
41
|
}
|
|
43
42
|
get jsonValidationErrorBodyResponse() {
|
|
44
|
-
return
|
|
43
|
+
return z.toJSONSchema(ValidationErrorBodyResponseSchema, { target: this.target });
|
|
45
44
|
}
|
|
46
45
|
get jsonFindQuerySchema() {
|
|
47
|
-
return
|
|
46
|
+
return z.toJSONSchema(FindQuerySchema, { target: this.target });
|
|
48
47
|
}
|
|
49
48
|
get jsonGroupByQuerySchema() {
|
|
50
|
-
return
|
|
49
|
+
return z.toJSONSchema(GroupByQuerySchema, { target: this.target });
|
|
51
50
|
}
|
|
52
51
|
get jsonSearchQuerySchema() {
|
|
53
|
-
return
|
|
52
|
+
return z.toJSONSchema(SearchQuerySchema, { target: this.target });
|
|
54
53
|
}
|
|
55
54
|
get jsonPaginateQuerySchema() {
|
|
56
|
-
return
|
|
55
|
+
return z.toJSONSchema(PaginateQuerySchema, { target: this.target });
|
|
57
56
|
}
|
|
58
57
|
get jsonDeleteBodyResponseSchema() {
|
|
59
|
-
return
|
|
58
|
+
return z.toJSONSchema(DeleteBodyResponseSchema, { target: this.target });
|
|
60
59
|
}
|
|
61
60
|
get jsonFindByParamSchema() {
|
|
62
|
-
return
|
|
61
|
+
return z.toJSONSchema(FindByParamSchema, { target: this.target });
|
|
63
62
|
}
|
|
64
63
|
get jsonPaginateBodyResponseSchema() {
|
|
65
|
-
return
|
|
64
|
+
return z.toJSONSchema(PaginateBodyResponseSchema.extend({
|
|
66
65
|
items: z.array(this.entitySchema)
|
|
67
66
|
}), { target: this.target });
|
|
68
67
|
}
|
|
69
68
|
get jsonIdParamSchema() {
|
|
70
|
-
return
|
|
69
|
+
return z.toJSONSchema(IdParamSchema, { target: this.target });
|
|
71
70
|
}
|
|
72
71
|
/**
|
|
73
72
|
* Get JSON schema for export
|
|
@@ -107,7 +106,7 @@ export class CrudSchemaBuilder {
|
|
|
107
106
|
get findByIdsSchema() {
|
|
108
107
|
return {
|
|
109
108
|
...(this.getTags),
|
|
110
|
-
params:
|
|
109
|
+
params: z.toJSONSchema(z.object({
|
|
111
110
|
ids: z.string().regex(/^[^,]+(,[^,]+)*$/, "Debe ser una lista de valores separados por coma sin comas consecutivas")
|
|
112
111
|
}), { target: this.target }),
|
|
113
112
|
response: {
|
|
@@ -283,7 +282,7 @@ export class CrudSchemaBuilder {
|
|
|
283
282
|
return {
|
|
284
283
|
...(this.getTags),
|
|
285
284
|
params: this.jsonIdParamSchema,
|
|
286
|
-
body:
|
|
285
|
+
body: z.toJSONSchema(this.entityUpdateSchema.partial(), { target: this.target }),
|
|
287
286
|
response: {
|
|
288
287
|
200: this.jsonEntitySchema,
|
|
289
288
|
401: this.jsonErrorBodyResponse,
|
|
@@ -178,6 +178,9 @@ class AbstractFastifyController extends CommonController {
|
|
|
178
178
|
async preCreate(request, payload) {
|
|
179
179
|
return payload;
|
|
180
180
|
}
|
|
181
|
+
async postCreate(request, item) {
|
|
182
|
+
return item;
|
|
183
|
+
}
|
|
181
184
|
async create(request, reply) {
|
|
182
185
|
try {
|
|
183
186
|
request.rbac.assertPermission(this.permission.Create);
|
|
@@ -186,6 +189,7 @@ class AbstractFastifyController extends CommonController {
|
|
|
186
189
|
await this.preCreate(request, payload);
|
|
187
190
|
let item = await this.service.create(payload);
|
|
188
191
|
this.onCreated(request, item);
|
|
192
|
+
await this.postCreate(request, item);
|
|
189
193
|
return item;
|
|
190
194
|
}
|
|
191
195
|
catch (e) {
|
|
@@ -195,6 +199,9 @@ class AbstractFastifyController extends CommonController {
|
|
|
195
199
|
async preUpdate(request, payload) {
|
|
196
200
|
return payload;
|
|
197
201
|
}
|
|
202
|
+
async postUpdate(request, item) {
|
|
203
|
+
return item;
|
|
204
|
+
}
|
|
198
205
|
async update(request, reply) {
|
|
199
206
|
try {
|
|
200
207
|
request.rbac.assertPermission(this.permission.Update);
|
|
@@ -221,6 +228,7 @@ class AbstractFastifyController extends CommonController {
|
|
|
221
228
|
throw new NotFoundError();
|
|
222
229
|
}
|
|
223
230
|
this.onUpdated(request, preItem, item);
|
|
231
|
+
await this.postUpdate(request, item);
|
|
224
232
|
return item;
|
|
225
233
|
}
|
|
226
234
|
catch (e) {
|
|
@@ -230,6 +238,9 @@ class AbstractFastifyController extends CommonController {
|
|
|
230
238
|
async preUpdatePartial(request, payload) {
|
|
231
239
|
return payload;
|
|
232
240
|
}
|
|
241
|
+
async postUpdatePartial(request, item) {
|
|
242
|
+
return item;
|
|
243
|
+
}
|
|
233
244
|
async updatePartial(request, reply) {
|
|
234
245
|
try {
|
|
235
246
|
request.rbac.assertPermission(this.permission.Update);
|
|
@@ -256,6 +267,7 @@ class AbstractFastifyController extends CommonController {
|
|
|
256
267
|
throw new NotFoundError();
|
|
257
268
|
}
|
|
258
269
|
this.onUpdated(request, preItem, item);
|
|
270
|
+
await this.postUpdatePartial(request, item);
|
|
259
271
|
return item;
|
|
260
272
|
}
|
|
261
273
|
catch (e) {
|
|
@@ -265,6 +277,9 @@ class AbstractFastifyController extends CommonController {
|
|
|
265
277
|
async preDelete(request, item) {
|
|
266
278
|
return item;
|
|
267
279
|
}
|
|
280
|
+
async postDelete(request, item) {
|
|
281
|
+
return item;
|
|
282
|
+
}
|
|
268
283
|
async delete(request, reply) {
|
|
269
284
|
try {
|
|
270
285
|
request.rbac.assertPermission(this.permission.Delete);
|
|
@@ -285,6 +300,7 @@ class AbstractFastifyController extends CommonController {
|
|
|
285
300
|
await this.preDelete(request, item);
|
|
286
301
|
await this.service.delete(id);
|
|
287
302
|
this.onDeleted(request, item);
|
|
303
|
+
await this.postDelete(request, item);
|
|
288
304
|
reply.send({
|
|
289
305
|
id: id,
|
|
290
306
|
message: 'Item deleted successfully',
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "1.1.0",
|
|
7
7
|
"description": "Crud utils across modules",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "types/index.d.ts",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"author": "Cristian Incarnato & Drax Team",
|
|
23
23
|
"license": "ISC",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@drax/common-back": "^0.
|
|
26
|
-
"@drax/common-share": "^0.
|
|
27
|
-
"@drax/identity-share": "^0.
|
|
28
|
-
"@drax/media-back": "^
|
|
25
|
+
"@drax/common-back": "^1.0.0",
|
|
26
|
+
"@drax/common-share": "^1.0.0",
|
|
27
|
+
"@drax/identity-share": "^1.0.0",
|
|
28
|
+
"@drax/media-back": "^1.1.0",
|
|
29
29
|
"@graphql-tools/load-files": "^7.0.0",
|
|
30
30
|
"@graphql-tools/merge": "^9.0.4",
|
|
31
31
|
"mongoose": "^8.21.0",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"dayjs": "^1.11.19",
|
|
37
37
|
"mongoose-paginate-v2": "^1.8.3",
|
|
38
|
-
"zod": "^3.
|
|
39
|
-
"zod-to-json-schema": "3.24.6"
|
|
38
|
+
"zod": "^4.3.6"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
41
|
"@types/node": "^20.12.10",
|
|
@@ -47,5 +46,5 @@
|
|
|
47
46
|
"tsc-alias": "^1.8.10",
|
|
48
47
|
"typescript": "^5.6.2"
|
|
49
48
|
},
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "dbbb8bf014f02236b5a8597c592b0382372eb00f"
|
|
51
50
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
-
|
|
3
|
-
import type { Targets } from 'zod-to-json-schema';
|
|
2
|
+
|
|
4
3
|
import {
|
|
5
4
|
IdParamSchema,
|
|
6
5
|
DeleteBodyResponseSchema,
|
|
@@ -21,9 +20,9 @@ export class CrudSchemaBuilder<T extends z.ZodObject<z.ZodRawShape>, TCreate ext
|
|
|
21
20
|
private entityUpdateSchema: TUpdate;
|
|
22
21
|
private entityName: string;
|
|
23
22
|
private tags: string[];
|
|
24
|
-
private target:
|
|
23
|
+
private target: string = 'openapi-3.0'; //"jsonSchema7" | "jsonSchema2019-09" | "openapi-3.0" | "openAi"
|
|
25
24
|
|
|
26
|
-
constructor(entitySchema: T, entityCreateSchema: TCreate, entityUpdateSchema: TUpdate, entityName: string, target:
|
|
25
|
+
constructor(entitySchema: T, entityCreateSchema: TCreate, entityUpdateSchema: TUpdate, entityName: string, target:string = 'openapi-3.0', tags: string[] = []) {
|
|
27
26
|
this.entitySchema = entitySchema;
|
|
28
27
|
this.entityCreateSchema = entityCreateSchema;
|
|
29
28
|
this.entityUpdateSchema = entityUpdateSchema;
|
|
@@ -40,23 +39,23 @@ export class CrudSchemaBuilder<T extends z.ZodObject<z.ZodRawShape>, TCreate ext
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
get jsonEntityCreateSchema(){
|
|
43
|
-
return
|
|
42
|
+
return z.toJSONSchema(this.entityCreateSchema, {target: this.target})
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
get jsonEntityUpdateSchema(){
|
|
47
|
-
return
|
|
46
|
+
return z.toJSONSchema(this.entityUpdateSchema, {target: this.target})
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
get jsonEntitySchema() {
|
|
51
|
-
return
|
|
50
|
+
return z.toJSONSchema(this.entitySchema, {target: this.target})
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
get jsonEntityArraySchema() {
|
|
55
|
-
return
|
|
54
|
+
return z.toJSONSchema(z.array(this.entitySchema), {target: this.target})
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
get jsonEntityGroupBySchema() {
|
|
59
|
-
return
|
|
58
|
+
return z.toJSONSchema(
|
|
60
59
|
z.array(
|
|
61
60
|
z.object({
|
|
62
61
|
count: z.number()
|
|
@@ -67,49 +66,49 @@ export class CrudSchemaBuilder<T extends z.ZodObject<z.ZodRawShape>, TCreate ext
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
get jsonExportBodyResponse() {
|
|
70
|
-
return
|
|
69
|
+
return z.toJSONSchema(ExportBodyResponseSchema, {target: this.target})
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
get jsonErrorBodyResponse() {
|
|
74
|
-
return
|
|
73
|
+
return z.toJSONSchema(ErrorBodyResponseSchema, {target: this.target})
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
get jsonValidationErrorBodyResponse() {
|
|
78
|
-
return
|
|
77
|
+
return z.toJSONSchema(ValidationErrorBodyResponseSchema, {target: this.target})
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
get jsonFindQuerySchema(){
|
|
82
|
-
return
|
|
81
|
+
return z.toJSONSchema(FindQuerySchema, {target: this.target})
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
get jsonGroupByQuerySchema(){
|
|
86
|
-
return
|
|
85
|
+
return z.toJSONSchema(GroupByQuerySchema, {target: this.target})
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
get jsonSearchQuerySchema(){
|
|
90
|
-
return
|
|
89
|
+
return z.toJSONSchema(SearchQuerySchema, {target: this.target})
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
get jsonPaginateQuerySchema(){
|
|
94
|
-
return
|
|
93
|
+
return z.toJSONSchema(PaginateQuerySchema, {target: this.target})
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
get jsonDeleteBodyResponseSchema(){
|
|
98
|
-
return
|
|
97
|
+
return z.toJSONSchema(DeleteBodyResponseSchema, {target: this.target})
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
get jsonFindByParamSchema(){
|
|
102
|
-
return
|
|
101
|
+
return z.toJSONSchema(FindByParamSchema, {target: this.target})
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
get jsonPaginateBodyResponseSchema(){
|
|
106
|
-
return
|
|
105
|
+
return z.toJSONSchema(PaginateBodyResponseSchema.extend({
|
|
107
106
|
items: z.array(this.entitySchema)
|
|
108
107
|
}), {target: this.target})
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
get jsonIdParamSchema(){
|
|
112
|
-
return
|
|
111
|
+
return z.toJSONSchema(IdParamSchema, {target: this.target})
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
/**
|
|
@@ -152,7 +151,7 @@ export class CrudSchemaBuilder<T extends z.ZodObject<z.ZodRawShape>, TCreate ext
|
|
|
152
151
|
get findByIdsSchema() {
|
|
153
152
|
return {
|
|
154
153
|
...(this.getTags),
|
|
155
|
-
params:
|
|
154
|
+
params: z.toJSONSchema(z.object({
|
|
156
155
|
ids: z.string().regex(/^[^,]+(,[^,]+)*$/, "Debe ser una lista de valores separados por coma sin comas consecutivas")
|
|
157
156
|
}), {target: this.target}),
|
|
158
157
|
response: {
|
|
@@ -339,7 +338,7 @@ export class CrudSchemaBuilder<T extends z.ZodObject<z.ZodRawShape>, TCreate ext
|
|
|
339
338
|
return {
|
|
340
339
|
...(this.getTags),
|
|
341
340
|
params: this.jsonIdParamSchema,
|
|
342
|
-
body:
|
|
341
|
+
body: z.toJSONSchema(this.entityUpdateSchema.partial(), {target: this.target}),
|
|
343
342
|
response: {
|
|
344
343
|
200: this.jsonEntitySchema,
|
|
345
344
|
401: this.jsonErrorBodyResponse,
|
|
@@ -270,6 +270,10 @@ class AbstractFastifyController<T, C, U> extends CommonController {
|
|
|
270
270
|
return payload
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
+
async postCreate(request: CustomRequest, item:T){
|
|
274
|
+
return item
|
|
275
|
+
}
|
|
276
|
+
|
|
273
277
|
async create(request: CustomRequest, reply: FastifyReply) {
|
|
274
278
|
try {
|
|
275
279
|
request.rbac.assertPermission(this.permission.Create)
|
|
@@ -278,6 +282,7 @@ class AbstractFastifyController<T, C, U> extends CommonController {
|
|
|
278
282
|
await this.preCreate(request, payload as C)
|
|
279
283
|
let item = await this.service.create(payload as C)
|
|
280
284
|
this.onCreated(request, item)
|
|
285
|
+
await this.postCreate(request, item as T)
|
|
281
286
|
return item
|
|
282
287
|
} catch (e) {
|
|
283
288
|
this.handleError(e, reply)
|
|
@@ -288,6 +293,10 @@ class AbstractFastifyController<T, C, U> extends CommonController {
|
|
|
288
293
|
return payload
|
|
289
294
|
}
|
|
290
295
|
|
|
296
|
+
async postUpdate(request: CustomRequest, item:T){
|
|
297
|
+
return item
|
|
298
|
+
}
|
|
299
|
+
|
|
291
300
|
async update(request: CustomRequest, reply: FastifyReply) {
|
|
292
301
|
try {
|
|
293
302
|
request.rbac.assertPermission(this.permission.Update)
|
|
@@ -323,6 +332,8 @@ class AbstractFastifyController<T, C, U> extends CommonController {
|
|
|
323
332
|
|
|
324
333
|
this.onUpdated(request, preItem, item)
|
|
325
334
|
|
|
335
|
+
await this.postUpdate(request, item as T)
|
|
336
|
+
|
|
326
337
|
return item
|
|
327
338
|
} catch (e) {
|
|
328
339
|
this.handleError(e, reply)
|
|
@@ -333,6 +344,10 @@ class AbstractFastifyController<T, C, U> extends CommonController {
|
|
|
333
344
|
return payload
|
|
334
345
|
}
|
|
335
346
|
|
|
347
|
+
async postUpdatePartial(request: CustomRequest, item:T){
|
|
348
|
+
return item
|
|
349
|
+
}
|
|
350
|
+
|
|
336
351
|
async updatePartial(request: CustomRequest, reply: FastifyReply) {
|
|
337
352
|
try {
|
|
338
353
|
request.rbac.assertPermission(this.permission.Update)
|
|
@@ -364,7 +379,11 @@ class AbstractFastifyController<T, C, U> extends CommonController {
|
|
|
364
379
|
if (!item) {
|
|
365
380
|
throw new NotFoundError()
|
|
366
381
|
}
|
|
382
|
+
|
|
367
383
|
this.onUpdated(request, preItem, item)
|
|
384
|
+
|
|
385
|
+
await this.postUpdatePartial(request, item as T)
|
|
386
|
+
|
|
368
387
|
return item
|
|
369
388
|
} catch (e) {
|
|
370
389
|
this.handleError(e, reply)
|
|
@@ -375,6 +394,9 @@ class AbstractFastifyController<T, C, U> extends CommonController {
|
|
|
375
394
|
return item
|
|
376
395
|
}
|
|
377
396
|
|
|
397
|
+
async postDelete(request: CustomRequest, item:T){
|
|
398
|
+
return item
|
|
399
|
+
}
|
|
378
400
|
|
|
379
401
|
async delete(request: CustomRequest, reply: FastifyReply) {
|
|
380
402
|
try {
|
|
@@ -400,10 +422,13 @@ class AbstractFastifyController<T, C, U> extends CommonController {
|
|
|
400
422
|
this.assertTenant(item, request.rbac)
|
|
401
423
|
|
|
402
424
|
await this.preDelete(request, item)
|
|
425
|
+
|
|
403
426
|
await this.service.delete(id)
|
|
404
427
|
|
|
405
428
|
this.onDeleted(request, item)
|
|
406
429
|
|
|
430
|
+
await this.postDelete(request, item)
|
|
431
|
+
|
|
407
432
|
reply.send({
|
|
408
433
|
id: id,
|
|
409
434
|
message: 'Item deleted successfully',
|