Apipie
Thanks Akiyamka for new project name!! (Previously called VueApify)
This is a tool for transforming the declaration of REST Api to js object. Inspired by VueRouter, koa2 and axios.
Why should i use it? Why? Why? Why?
Installation
# Using yarn: yarn add apipie# Using npm: npm install apipie
Using CDN:
const hook = async { console await } const data = trueconst params = true const decl = name: 'user' // Further you'll use it as `api.user()` for sending request // All of the options you'll find https://github.com/mzabriskie/axios#request-config options: ... url: '/user/:id' method: 'get' // You can not call api.settings(), but api.settings.get() will be available name: 'settings' url: '/settings' method: 'get' children: name: 'setStatus' url: '/set_status' method: 'post' params // or params: true if do not prefer shorthand property names syntax }, name: 'changeAvatar' url: '/change_avatar' method: 'post' const apipie = decl axios apipie // Global hook is also availableconst api = apipie // Oop, throw error becouse required :id url_paramsapi // GET: /user/undefined// That's okapi // GET: /user/1 apisettings // Oops, expect params! // POST: /set_status?status=my_statusapisettings const avatar = // ...apisettings
Documentations
TODO
- Stacking of paths
- More examples