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.
23 lines (19 loc) • 439 B
JavaScript
import { success } from '../helper/response'
import * as repository from '../lib/repository'
/**
* Creates a new record
*
* @param {Schema} model The current model
* @returns {Function} An express-middleware
*/
const __post = model => {
const create = repository.create(model)
return (req, res, next) => {
create(req.body)
.then(response => {
success(200, response, res)
})
.catch(next)
}
}
export default __post