@elsikora/nestjs-crud-automator
Version:
A library for automating the creation of CRUD operations in NestJS.
30 lines (27 loc) • 1.38 kB
JavaScript
import { __decorate } from '../external/tslib/tslib.es6.js';
import { ApiRouteRuntime } from '../class/api/route-runtime.class.js';
import '../constant/decorator/api/function.constant.js';
import { METHOD_API_DECORATOR_CONSTANT } from '../constant/decorator/api/method.constant.js';
import { Injectable } from '@nestjs/common';
import { from } from '../external/rxjs/dist/esm5/internal/observable/from.js';
import { lastValueFrom } from '../external/rxjs/dist/esm5/internal/lastValueFrom.js';
let ApiRouteRuntimeInterceptor = class ApiRouteRuntimeInterceptor {
intercept(context, next) {
const metadata = Reflect.getMetadata(METHOD_API_DECORATOR_CONSTANT.ROUTE_METADATA_KEY, context.getHandler());
const runtimeProperties = Reflect.getMetadata(METHOD_API_DECORATOR_CONSTANT.ROUTE_RUNTIME_PROPERTIES_METADATA_KEY, context.getHandler());
if (!metadata) {
return next.handle();
}
return from(ApiRouteRuntime.executeCustom({
executionContext: context,
metadata,
operation: async () => await lastValueFrom(next.handle()),
runtimeProperties: runtimeProperties ?? {},
}));
}
};
ApiRouteRuntimeInterceptor = __decorate([
Injectable()
], ApiRouteRuntimeInterceptor);
export { ApiRouteRuntimeInterceptor };
//# sourceMappingURL=api-route-runtime.interceptor.js.map