@elsikora/nestjs-crud-automator
Version:
A library for automating the creation of CRUD operations in NestJS.
28 lines (25 loc) • 1.09 kB
JavaScript
import { HttpStatus } from '@nestjs/common';
import { ApiRouteSerializeResponse } from '../route/response/serialize.utility.js';
/**
* Serializes a generated route response with the route DTO and serialization settings.
* @template E - Entity type owned by the route.
* @template R - Response value type.
* @param {TApiControllerPropertiesRoute<E, EApiRouteType>} routeConfig - Route configuration containing response serialization settings.
* @param {Type<unknown> | undefined} dto - DTO type used for response serialization.
* @param {R} response - Response value to serialize.
* @returns {R} Serialized response value.
*/
function ApiControllerSerializeRouteResponse(routeConfig, dto, response) {
const serialization = routeConfig.response?.serialization ?? {
isEnabled: true,
};
return ApiRouteSerializeResponse({
response: {
serialization,
status: HttpStatus.OK,
type: dto,
},
}, response);
}
export { ApiControllerSerializeRouteResponse };
//# sourceMappingURL=serialize-route-response.utility.js.map