UNPKG

jambda

Version:

Easy serverless rest api deploy! Jambda makes it easy to deploy database connected rest api's by providing the least amount of configuration.

32 lines (27 loc) 627 B
import { success } from '../helper/response' import * as repository from '../lib/repository' import { notFound } from 'boom' /** * Patches an existing entity * * @param {Schema} model The current model * @returns {Function} An express-middleware */ const __patch = model => { const patch = repository.patch(model) return (req, res, next) => { patch(req.params.id, req.body) .then(response => { if (!response) { return next( notFound( `Resource with id ${req.params.id} does not exist!` ) ) } success(200, response, res) }) .catch(next) } } export default __patch