-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for metadata middleware (#507)
* WIP support for metadata middleware * Added unit tests and docs
- Loading branch information
1 parent
96230ab
commit d60a053
Showing
15 changed files
with
441 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { interfaces } from "../interfaces/interfaces"; | ||
import * as METADATA_KEY from "../constants/metadata_keys"; | ||
|
||
class MetadataReader implements interfaces.MetadataReader { | ||
|
||
public getConstrucotorMetadata(constructorFunc: Function): interfaces.ConstructorMetadata { | ||
|
||
// TypeScript compiler generated annotations | ||
let compilerGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.PARAM_TYPES, constructorFunc); | ||
|
||
// User generated constructor annotations | ||
let userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED, constructorFunc); | ||
|
||
return { | ||
compilerGeneratedMetadata: compilerGeneratedMetadata, | ||
userGeneratedMetadata: userGeneratedMetadata || {} | ||
}; | ||
|
||
} | ||
|
||
public getPropertiesMetadata(constructorFunc: Function): interfaces.MetadataMap { | ||
// User generated properties annotations | ||
let userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED_PROP, constructorFunc) || []; | ||
return userGeneratedMetadata; | ||
} | ||
|
||
} | ||
|
||
export { MetadataReader }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.