lasagne

1.0.4-alpha • Public • Published

Lasagne Build Status

Easy way to mock api locally

Installation

You can install lasagne from npm with yarn:

yarn add lasagne

Or with npm:

npm i lasagne

Core concept and usage

Lasagne was created for make work without api more standartized and allow to make easy switch between remote api and local api layers.

import { lasagne, registerLayer } from 'lasagne'
 
const root = {
  '/': () => ({ foo: 'bar' }),
  '/item': ({ id }) => {
    return localStorage.getItem(`test-storage-${id}`)
  }
}
 
registerLayer('root', root)
 
;(async () => {
  const res = await lasagne('/') // { foo: bar }
  const item = await lasagne('/item', { id: 1 }) // ...
})

Then we can replace lasagne with fetch or something else to work with remote api layer.

Roadmap

  • Make allow to mock fetch and other libs for more flexability

Readme

Keywords

none

Package Sidebar

Install

npm i lasagne

Weekly Downloads

1

Version

1.0.4-alpha

License

MIT

Unpacked Size

7.23 kB

Total Files

20

Last publish

Collaborators

  • lamartire