kobp
Version:
Koa Boilerplate with MikroORM
23 lines • 911 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.withValidation = void 0;
// interface SchemaParser {
// <T>(parsable: Parsable<T>): T
// }
// const query = <T>(schema: Parsable<T>) => tinyParser('query', schema)
// const body = <T>(schema: Parsable<T>) => tinyParser('body', schema)
// const params = <T>(schema: Parsable<T>) => tinyParser('params', schema)
//
// const tinyParser = <L extends 'query' | 'body' | 'params', LT>(location: L, schema: Parsable<any>) => {}
const withValidation = (schemaSpec) => {
// TODO: build up a parser for this route
return async (context, next) => {
const query = context.query;
const params = context.params;
const body = context.body;
schemaSpec.parse({ query, params, body });
await next();
};
};
exports.withValidation = withValidation;
//# sourceMappingURL=withValidations.js.map