dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
18 lines (17 loc) • 608 B
JavaScript
import { $interceptor } from './constants.js';
export const interceptable = () => {
return (_, __, descriptor) => {
const originalValue = descriptor.value;
descriptor.value = async function (...args) {
const action = this;
const interceptor = action.table[$interceptor];
if (interceptor !== undefined) {
const response = await interceptor(action);
if (response !== undefined) {
return response;
}
}
return originalValue.apply(this, args);
};
};
};