UNPKG

@indiekit/endpoint-posts

Version:

Post management endpoint for Indiekit. View posts published by your Micropub endpoint and publish new posts to it.

24 lines (19 loc) 554 B
import { check, checkSchema } from "express-validator"; export const validate = { async form(request, response, next) { const { validationSchemas } = request.app.locals; const validations = []; for (const schema of [Object.fromEntries(validationSchemas)]) { validations.push(checkSchema(schema)); } for (let validation of validations) { await validation.run(request); } next(); }, new: [ check("type") .exists() .withMessage((value, { req }) => req.__("posts.error.type.empty")), ], };