UNPKG

@nestjs/config

Version:

Nest - modern, fast, powerful node.js web framework (@config)

30 lines (29 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerAs = registerAs; const __1 = require(".."); const config_constants_1 = require("../config.constants"); const get_config_token_util_1 = require("./get-config-token.util"); /** * @publicApi * * Registers the configuration object behind a specified token. */ function registerAs(token, configFactory) { const defineProperty = (key, value) => { Object.defineProperty(configFactory, key, { configurable: false, enumerable: false, value, writable: false, }); }; defineProperty(config_constants_1.PARTIAL_CONFIGURATION_KEY, token); defineProperty(config_constants_1.PARTIAL_CONFIGURATION_PROPNAME, (0, get_config_token_util_1.getConfigToken)(token)); defineProperty(config_constants_1.AS_PROVIDER_METHOD_KEY, () => ({ imports: [__1.ConfigModule.forFeature(configFactory)], useFactory: (config) => config, inject: [(0, get_config_token_util_1.getConfigToken)(token)], })); return configFactory; }