🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

koa-falcor

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-falcor

Koa Middleware for Hosting Falcor Data Sources.

latest
Source
npmnpm
Version
0.6.1
Version published
Maintainers
1
Created
Source

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)

Keywords

koa

FAQs

Package last updated on 11 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts