UNPKG

1.14 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.Module = void 0;
4const validate_module_keys_util_1 = require("../../utils/validate-module-keys.util");
5/**
6 * Decorator that marks a class as a [module](https://docs.nestjs.com/modules).
7 *
8 * Modules are used by Nest to organize the application structure into scopes. Controllers
9 * and Providers are scoped by the module they are declared in. Modules and their
10 * classes (Controllers and Providers) form a graph that determines how Nest
11 * performs [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
12 *
13 * @param metadata module configuration metadata
14 *
15 * @see [Modules](https://docs.nestjs.com/modules)
16 *
17 * @publicApi
18 */
19function Module(metadata) {
20 const propsKeys = Object.keys(metadata);
21 validate_module_keys_util_1.validateModuleKeys(propsKeys);
22 return (target) => {
23 for (const property in metadata) {
24 if (metadata.hasOwnProperty(property)) {
25 Reflect.defineMetadata(property, metadata[property], target);
26 }
27 }
28 };
29}
30exports.Module = Module;