recoder-code
Version:
🚀 AI-powered development platform - Chat with 32+ models, build projects, automate workflows. Free models included!
30 lines (29 loc) • 1.1 kB
JavaScript
;
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;
}