nope/lib/decorators/moduelDecorators.ts

31 lines
975 B
TypeScript
Raw Normal View History

2020-11-05 17:01:38 +00:00
import { IFunctionOptions, INopeModule, IPropertyOptions } from "../types/nopeModule.interface";
/**
* Decorator, used to export the Method.
* @param options
*/
export function exportMethod(options: IFunctionOptions) {
return function (target: INopeModule, methodName: string, descriptor: PropertyDescriptor) {
target._markedElements = target._markedElements || [];
target._markedElements.push({
accessor: methodName,
options,
type: 'method'
});
};
}
/**
* Decorator, will create a POST and GET api for the Parameter.
* @param options
*/
export function exportProperty(options: IPropertyOptions) {
return function (target: INopeModule, propertyKey: string, descriptor: PropertyDescriptor) {
target._markedElements = target._markedElements || [];
target._markedElements.push({
accessor: propertyKey,
options,
type: 'prop'
});
};
}