UNPKG

1.11 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.registerAs = void 0;
4const __1 = require("..");
5const config_constants_1 = require("../config.constants");
6const get_config_token_util_1 = require("./get-config-token.util");
7/**
8 * Registers the configuration object behind a specified token.
9 */
10function registerAs(token, configFactory) {
11 const defineProperty = (key, value) => {
12 Object.defineProperty(configFactory, key, {
13 configurable: false,
14 enumerable: false,
15 value,
16 writable: false,
17 });
18 };
19 defineProperty(config_constants_1.PARTIAL_CONFIGURATION_KEY, token);
20 defineProperty(config_constants_1.PARTIAL_CONFIGURATION_PROPNAME, (0, get_config_token_util_1.getConfigToken)(token));
21 defineProperty(config_constants_1.AS_PROVIDER_METHOD_KEY, () => ({
22 imports: [__1.ConfigModule.forFeature(configFactory)],
23 useFactory: (config) => config,
24 inject: [(0, get_config_token_util_1.getConfigToken)(token)],
25 }));
26 return configFactory;
27}
28exports.registerAs = registerAs;