efesto-angular

0.4.2 • Public • Published

Efesto Angular

Angular sdk for Efesto that provides an angular module that handles authentication and requests to an Efesto API.

Installation

Install using npm:

npm install efesto-angular

Then load the module:

angular.module('myapp', ['efesto.angular']);

Usage

Set the domain where the api is located:

api.domain = 'http://youdomain.com';

Set the credentials for an user:

api.addUser('myuser', 'password');

Login with that user:

api.login('myuser', successCallback);

Now you can make requests to collections:

/* Get list of users */
var users = api.collection('users');
users.get({rank: 1}, successCallback, failureCallback);

/* New user */
var myUser = {name: 'myself', rank: 1, email: 'mail', password: 'passwd'};
users.post(myUser, null, successCallback, failureCallback);

To resources:

var user = api.resource('users');
/* Get user with id 7 */
user.get({id: 7}, successCallback, failureCallback);

/* Update user #7's name */
user.patch({id: 7, name: 'newname'}, successCallback, failureCallback);

/* Delete user #7 */
user.delete({id: 7}, successCallback, failureCallback);

If you already know your token, such as when using a public user:

api.addToken('public', 'mytoken')
api.user.currentUser = 'public';

Readme

Keywords

none

Package Sidebar

Install

npm i efesto-angular

Weekly Downloads

0

Version

0.4.2

License

MIT

Last publish

Collaborators

  • vesuvium