UNPKG

@solid-nestjs/rest-api

Version:

solid-nestjs Rest-API utilities

72 lines 2.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataControllerStructureEx = DataControllerStructureEx; const common_1 = require("@solid-nestjs/common"); /** * Creates an enhanced data controller structure configuration with plugin support. * * This function helps configure a data REST API controller structure that can be extended * with plugins. The structure defines all the necessary configurations for creating a * controller that supports read-only data operations (List, Get by ID) with * plugin-enhanced functionality. * * @template IdType - The type of the entity's identifier (string, number, etc.) * @template EntityType - The entity type this controller will operate on * @template ServiceType - The data service type that provides business logic * @template FindArgsType - The type for filtering/pagination parameters * @template ContextType - The request context type (defaults to Context) * @template PluginArrayType - Array of controller plugins to apply * * @param input - Configuration object containing: * - entityType: The entity class * - serviceType: The data service class * - route?: Base route path for the controller * - operations?: Configuration for which data operations to enable/disable * - plugins?: Array of controller plugins to apply * - ...additional plugin-specific options * * @returns Enhanced controller structure with plugin support and type-safe configuration * * @example * ```typescript * // Basic data controller structure with caching plugin * const userDataControllerStructure = DataControllerStructureEx({ * entityType: User, * serviceType: UserDataService, * route: 'users', * plugins: [cachePlugin], * operations: { * findAll: { route: 'list' }, * findOne: { route: ':id' }, * pagination: false // Disable pagination endpoint * } * }); * * // Advanced structure with multiple plugins for analytics * const productDataControllerStructure = DataControllerStructureEx({ * entityType: Product, * serviceType: ProductDataService, * plugins: [analyticsPlugin, cachePlugin, rateLimit], * * // Plugin-specific options are type-safe * trackViews: true, // from analyticsPlugin * cacheTtl: 600, // from cachePlugin * rateLimit: { max: 100, windowMs: 60000 }, // from rateLimit * * operations: { * findAll: { * decorators: [() => UseInterceptors(LoggingInterceptor)] * } * } * }); * ``` * * @see {@link DataControllerStructure} - Base controller structure interface * @see {@link ControllerPlugin} - Plugin interface for extending controllers * @see {@link DataControllerExFrom} - Factory for creating controller classes from structures */ function DataControllerStructureEx(input) { (0, common_1.fillEntityId)(input); return input; } //# sourceMappingURL=data-controller-extended-structure.interface.js.map