Now Playing Mario

    koa-falcor

    0.6.1 • Public • Published

    koa-falcor

    Koa Middleware for Hosting Falcor Data Sources.

    dataSourceRoute is port from falcor-express.

    Installation

    npm install koa-falcor koa koa-route --save

    Usage

    const falcor = require('koa-falcor')
    const Koa = require('koa')
    const route = require('koa-route')
     
    const app = new Koa()
     
    app.use(route.get('/model.json', falcor([{
      route: 'greeting',
      get() {
        return {
          path: ['greeting'],
          value: 'Hello World!',
        }
      },
    }])))
     
    app.listen(3000)

    Then access the JSON Graph via http://localhost:3000/model.json?paths=[["greeting"]]&method=get

    Create Router Manually

    npm install koa-falcor koa koa-bodyparser koa-route falcor-router --save
    const { dataSourceRoute } = require('koa-falcor')
    const bodyParser = require('koa-bodyparser')
    const Koa = require('koa')
    const route = require('koa-route')
    const Router = require('falcor-router')
     
    const app = new Koa()
     
    app.use(bodyParser())
    app.use(route.get('/model.json', dataSourceRoute(() => new Router([{
      route: 'greeting',
      get() {
        return {
          path: ['greeting'],
          value: 'Hello World!',
        }
      },
    }]))))
     
    app.listen(3000)

    Install

    npm i koa-falcor

    DownloadsWeekly Downloads

    9

    Version

    0.6.1

    License

    MIT

    Unpacked Size

    5.14 kB

    Total Files

    4

    Last publish

    Collaborators

    • ratson