@nest-omni/core 3.1.2-3 → 3.1.2-7
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/common/dto/dto-extensions.js +11 -15
- package/package.json +1 -1
- package/setup/bootstrap.setup.js +1 -5
|
@@ -33,31 +33,27 @@ typeorm_1.SelectQueryBuilder.prototype.toDtoPage = function (pageOptionsDto, dto
|
|
|
33
33
|
const page = pageOptionsDto.page || 1;
|
|
34
34
|
const pageSize = pageOptionsDto.pageSize || 10;
|
|
35
35
|
const skip = (page - 1) * pageSize;
|
|
36
|
-
const
|
|
37
|
-
const entities = yield this
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
.getMany();
|
|
41
|
-
if (entities.length > 0) {
|
|
36
|
+
const total = yield this.getCount();
|
|
37
|
+
const entities = yield this.skip(skip).take(pageSize).getMany();
|
|
38
|
+
const count = entities.length;
|
|
39
|
+
if (count) {
|
|
42
40
|
console.log('Raw entity sample:', JSON.stringify(entities[0], null, 2));
|
|
43
41
|
}
|
|
44
42
|
const data = yield entities.toDto(dtoClass, context);
|
|
45
43
|
if (data.length > 0) {
|
|
46
44
|
console.log('Converted DTO sample:', JSON.stringify(data[0], null, 2));
|
|
47
45
|
}
|
|
48
|
-
const
|
|
49
|
-
const pageCount = Math.ceil(itemCount / pageSize);
|
|
46
|
+
const pageCount = Math.ceil(total / pageSize);
|
|
50
47
|
const hasPreviousPage = page > 1;
|
|
51
48
|
const hasNextPage = page < pageCount;
|
|
52
49
|
return {
|
|
53
50
|
data,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
51
|
+
count,
|
|
52
|
+
total,
|
|
53
|
+
page,
|
|
54
|
+
pageCount,
|
|
55
|
+
hasPreviousPage,
|
|
56
|
+
hasNextPage,
|
|
61
57
|
};
|
|
62
58
|
});
|
|
63
59
|
};
|
package/package.json
CHANGED
package/setup/bootstrap.setup.js
CHANGED
|
@@ -139,11 +139,7 @@ function bootstrapSetup(AppModule, SetupSwagger) {
|
|
|
139
139
|
app.enableShutdownHooks();
|
|
140
140
|
app.enableVersioning();
|
|
141
141
|
app.enable('trust proxy');
|
|
142
|
-
app.
|
|
143
|
-
app.use(bodyParse.urlencoded({
|
|
144
|
-
extended: true,
|
|
145
|
-
parameterLimit: 1000,
|
|
146
|
-
}), bodyParse.json({ limit: '50mb' }), new nestjs_cls_1.ClsMiddleware({
|
|
142
|
+
app.use(bodyParse.json({ limit: '50mb' }), new nestjs_cls_1.ClsMiddleware({
|
|
147
143
|
saveReq: true,
|
|
148
144
|
}).use, (0, __1.RequestIdMiddleware)(), (0, __1.PowerByMiddleware)(), (0, __1.OmniAuthMiddleware)(), compression());
|
|
149
145
|
const reflector = app.get(core_1.Reflector);
|