lasagne
v1.0.4-alpha
Published
Easy way to mock api locally
Downloads
3
Readme
Lasagne
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