Skip to content

HeroMock/Reed-Json-API

Repository files navigation

Reed Json API

KOA middleware for Json Rest API

Sample

    const app = new Koa(),
        filePath = path.join(process.cwd(), 'json-api.hbs'),
        options = { urlPrefix: '/api', filePath}

    app.use(koaBody())
    app.use(api(options))

    app.use(ctx => {
        ctx.status = 404
        ctx.body = { error: 'not found' }
    })

    return app.listen(8000)

Options

urlPrefix: Optional Set the URL path prefix

filePath: Required file path to the json template The json is generated by dummy json.

dummyOptions: Optional options when parsing dummy json. see here for more detail.

About

KOA middleware for Json Rest API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •