Skip to content

Commit

Permalink
feature(@common) rename modules to imports property
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Dec 21, 2017
1 parent 2a727b9 commit 864fac9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const metadata = {
MODULES: 'modules',
IMPORTS: 'imports',
COMPONENTS: 'components',
CONTROLLERS: 'controllers',
EXPORTS: 'exports',
Expand Down
9 changes: 8 additions & 1 deletion src/common/decorators/modules/module.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { metadata } from '../../constants';

const metadataKeys = [
metadata.MODULES,
metadata.IMPORTS,
metadata.EXPORTS,
metadata.COMPONENTS,
metadata.CONTROLLERS,
Expand All @@ -22,21 +23,27 @@ const validateKeys = (keys: string[]) => {

/**
* Defines the module
* - `modules` - the set of the 'imported' modules
* - `modules` - @deprecated the set of the 'imported' modules
* - `imports` - the set of the 'imported' modules
* - `controllers` - the list of controllers (e.g. HTTP controllers)
* - `components` - the list of components that belong to this module. They can be injected between themselves.
* - `exports` - the set of components, which should be available for modules, which imports this module
* @param obj {ModuleMetadata} Module metadata
*/
export function Module(obj: {
modules?: any[];
imports?: any[],
controllers?: any[];
components?: any[];
exports?: any[];
}): ClassDecorator {
const propsKeys = Object.keys(obj);
validateKeys(propsKeys);

obj.modules = obj.imports && !obj.modules
? obj.imports
: obj.modules;

return (target: object) => {
for (const property in obj) {
if (obj.hasOwnProperty(property)) {
Expand Down

0 comments on commit 864fac9

Please sign in to comment.