/generic-middleware-utils

Utility functions to generate middleware functions for http-interfaces

Primary LanguageJavaScript

generic-middleware-utils

Utility functions to generate middleware functions for http-interfaces. Reduces the amount of work in creating CRUD-style interfaces.

Example

import Koa from 'koa'
import MyModel from './MyModel'
import createInterface from './lib/'

const HTTP_PORT = process.env.HTTP_PORT || 32123
const app = new Koa()
const myModelRouter = createInterface('/my-model', MyModel)

app.use(myModelRouter.routes(), myModelRouter.allowedMethods())

app.listen(HTTP_PORT)

API

createInterface(routerOrPath, pathOrModel, ModelOrUndefined)

Creates endpoints for router.