smappy
Version:
A lightweight, profile-based mapping library for NestJS.
24 lines (23 loc) • 752 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mapper = Mapper;
exports.isMapper = isMapper;
const common_1 = require("@nestjs/common");
const constant_1 = require("./constant");
/**
* Marks a class as a mapper and as injectable. (The class should implement the `IMapper` interface.)
*/
function Mapper() {
return (target) => {
Reflect.defineMetadata(constant_1.MAPPER_METADATA_KEY, true, target);
(0, common_1.Injectable)()(target);
};
}
/**
* Utility function to check if a class is a mapper
* @param target Class to check
* @returns Verifies if the class is a mapper
*/
function isMapper(target) {
return Reflect.getMetadata(constant_1.MAPPER_METADATA_KEY, target) === true;
}