nope/lib/decorators/moduleDecorators.ts
2020-12-04 19:10:33 +01:00

52 lines
1.1 KiB
TypeScript

/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2020-11-06 08:52:45
* @modify date 2020-12-02 08:56:41
* @desc [description]
*/
import {
IFunctionOptions,
INopeModule,
IPropertyOptions
} from "../types/nope/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"
});
};
}