@russ-b/nestjs-common-tools
Version:
NestJS utility tools
79 lines • 2.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPaginatedResponseSchema = createPaginatedResponseSchema;
exports.createLegacyPaginatedResponseSchema = createLegacyPaginatedResponseSchema;
function createPaginationMetaSchema() {
return {
type: 'object',
required: ['total', 'pages', 'page', 'perPage'],
properties: {
total: {
type: 'integer',
example: 125,
},
pages: {
type: 'integer',
example: 13,
},
page: {
type: 'integer',
example: 1,
},
perPage: {
type: 'integer',
example: 10,
},
},
};
}
function createLegacyPaginationMetaSchema() {
return {
type: 'object',
required: ['totalItems', 'totalPages', 'page', 'perPage'],
properties: {
totalItems: {
type: 'integer',
example: 125,
},
totalPages: {
type: 'integer',
example: 13,
},
page: {
type: 'integer',
example: 1,
},
perPage: {
type: 'integer',
example: 10,
},
},
};
}
function createPaginatedResponseSchema(itemSchema) {
return {
type: 'object',
required: ['data', 'pagination'],
properties: {
data: {
type: 'array',
items: itemSchema,
},
pagination: createPaginationMetaSchema(),
},
};
}
function createLegacyPaginatedResponseSchema(itemSchema) {
return {
type: 'object',
required: ['data', 'pagination'],
properties: {
data: {
type: 'array',
items: itemSchema,
},
pagination: createLegacyPaginationMetaSchema(),
},
};
}
//# sourceMappingURL=paginated-response.schema.js.map