Javascript ORM for consuming Restful APIs.
Premiere is standalone (independent of framework), so you can use it with your favorite library/framework, be it MobX React, Angular, VueJS, jQuery, Redux. You name it!
We recommend the use with TypeScript or ECMAScript 6 (ES6).
For a better experience, please checkout the Website
** For more about how promises work, check out Dave Atchley's article
- 100% Unit Tested
- Normalization
- Smart Caching
- Support to Foreign keys
- HTTP Header support (frequently used with Authorization and CSRF token)
Using npm:
$ npm install premiere --save
Using cdn:
<script src="https://unpkg.com/premiere/dist/premiere.min.js"></script>
Note: You'll need a ES6 polyfill on your build pipeline.
This code is written in TypeScript.
import {Api, api, Model} from 'premiere';
Api.base = 'http://rest.learncode.academy/api/YOUR_NAME_HERE/';
/*
* Using API directly
*/
api.http().get('albums'); // GET http://rest.learncode.academy/api/YOUR_NAME_HERE/albums
api.http().post('albums'); // POST http://rest.learncode.academy/api/YOUR_NAME_HERE/albums
/*
* Using Models
*/
class Album extends Model {
static path = 'albums';
id: number;
name: string;
}
Album.all(); // GET http://rest.learncode.academy/api/YOUR_NAME_HERE/albums
Album.find(1); // GET http://rest.learncode.academy/api/YOUR_NAME_HERE/albums/1
Album.save({name: 'new album'});// POST http://rest.learncode.academy/api/YOUR_NAME_HERE/albums
The tutorials are written in TypeScript.
- Working with Models
- Working with Foreign Keys
- Customizing Stores
- Working with Cache
- APIs without Models
Check out the full Documentation.
- Book List (ES6 - JSFiddle)
- Premiere Player (ES6 + React + MobX)
- axios for handling HTTP Requests.
- https://medium.com/@pedsmoreira/consuming-restful-apis-with-premiere-ae712d1bc935#.ki5e8biu3
- https://medium.com/@pedsmoreira/from-0-to-100-coverage-real-quick-d71dda7069e5#.sceucnhmf
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.