@enter-at/lambda-handlers
Version:
An opinionated Typescript package that facilitates specifying AWS Lambda handlers including input validation, error handling and response formatting.
23 lines (22 loc) • 632 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.format = void 0;
class FormatDecorator {
contentType;
formatter;
constructor(contentType, formatter) {
this.contentType = contentType;
this.formatter = formatter;
}
apply(content) {
return this.formatter(content);
}
}
function format(contentType) {
function wrapper(_target, _propertyName, propertyDescriptor) {
propertyDescriptor.value = new FormatDecorator(contentType, propertyDescriptor.value);
return propertyDescriptor;
}
return wrapper;
}
exports.format = format;