kobp
Version:
Koa Boilerplate with MikroORM
14 lines • 499 B
JavaScript
import { METADATA_KEYS, OperationDocumentBuilder } from './doc.helpers';
/**
* The Passthrough Middleware that inject document's metadata
*/
export const withDocument = (doc) => {
const fn = async (_ctx, next) => {
await next();
};
// Define documents
const out = typeof doc === 'function' ? () => doc(new OperationDocumentBuilder()).build() : () => doc;
Reflect.defineMetadata(METADATA_KEYS.DOC_KEY, out, fn);
return fn;
};
//# sourceMappingURL=withDocument.js.map