UNPKG

@nestjs-mod/common

Version:

A collection of utilities for unifying NestJS applications and modules

30 lines 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigModel = ConfigModel; exports.ConfigModelProperty = ConfigModelProperty; const common_1 = require("@nestjs/common"); const constants_1 = require("./constants"); /** * Decorator to mark a class as a configuration model * @param options Optional configuration for the model */ function ConfigModel(options) { return (0, common_1.applyDecorators)((0, common_1.Injectable)(), (target) => { Reflect.defineMetadata(constants_1.CONFIG_MODEL_METADATA, { ...options, originalName: target.name, }, target); }); } /** * Decorator to define a property within a configuration model * @param options Property configuration options (excluding originalName and propertyKey) */ function ConfigModelProperty(options) { return (target, propertyKey) => { const existingMetadata = Reflect.getOwnMetadata(constants_1.CONFIG_MODEL_PROPERTIES_METADATA, target.constructor) || []; existingMetadata.push({ ...options, originalName: propertyKey }); Reflect.defineMetadata(constants_1.CONFIG_MODEL_PROPERTIES_METADATA, existingMetadata, target.constructor); }; } //# sourceMappingURL=decorators.js.map