A simple way to consume APIs with Javascript.
Premiere helps you reducing the amount of boilerplate necessary to consume APIs. Here's an example of how it looks like:
;todoList.title = 'Daily routine';todoList.save; // Get user by todo list; // Get items from todo list; // List all todo lists by user;
- Friendly syntax, inspired by Eloquent (Laravel) and ActiveRecord (Rails)
- Normalization
- Normalize data coming from the API
- Denormalize data before sending to the API
- Smart Caching to speed up your app
- Automatic request and result caching
- Automatic cache removal (for lists) upon saving a record
- Support to Foreign keys
- Support to HTTP Header settings
- JWT token helper
- CSRF token helper
Workflow
** For more about how promises work, check out Dave Atchley's article
Installation
Using npm:
npm install premiere --save
Getting Started
Setting API url
;api.base = 'http://api.com'
Creating a new model
;;; // Set your api baseapi.base = 'http://my-api.com'; // Define your model // Create new todo list;todoList.user_id = 1;todoList.title = 'Daily routine';todoList.save; // Get user by todo list; // Get items from todo list; // List all todo lists by user;
Tutorials
The tutorials are written in TypeScript.
Dependencies
- axios for handling HTTP Requests.
Resources
-
The logo was created by Yannick Lung and can be found here.
Articles
- V0.1
Motivation
Premiere is inspired by Laravel (Eloquent) and Rails (Active Record).
Because of frameworks like these, building Restful APIs is a much smoother path.
The goal of Premiere is to provide the same facility and power that these libraries provide, just this time on the client side.