Giter Site home page Giter Site logo

ng-feathers's Introduction

npm Bower Travis Code Climate Gemnasium js-standard-style Beevelop

ngFeathers ๐Ÿฆ

โš ๏ธ Still WIP: API is unstable and might change.

FeatherJS for plain old AngularJS (1.X)

Installation

Install via Bower:

bower install --save ng-feathers

Add standalone version (dependencies included) to your HTML file

<script src="bower_components/ng-feathers/dist/ng-feathers.standalone.min.js"></script>

Or add Socket.io + Feathers-Client + (minified) ngFeathers individually:

<script src="bower_components/socket.io-client/socket.io.js"></script>
<script src="bower_components/feathers-client/dist/feathers.js"></script>
<script src="bower_components/ng-feathers/dist/ng-feathers.min.js"></script>

Install via npm:

npm install --save ng-feathers

Add standalone version (dependencies included) to your HTML file

<script src="node_modules/ng-feathers/dist/ng-feathers.standalone.min.js"></script>

Or add Socket.io + Feathers-Client + (minified) ngFeathers individually:

<script src="node_modules/socket.io-client/socket.io.js"></script>
<script src="node_modules/feathers-client/dist/feathers.js"></script>
<script src="node_modules/ng-feathers/dist/ng-feathers.min.js"></script>

REST

  • REST requires jQuery as it depends on jQuery's AJAX implementation

Usage (with Socket.io)

// Add ngFeathers as dependency
angular.module('myApp', ['ngFeathers'])

  // Optionally configure $feathersProvider
  .config(function ($feathersProvider) {
    $feathersProvider.setEndpoint('http://localhost:3030')

    // You can optionally provide additional opts for socket.io-client
    $feathersProvider.setSocketOpts({
      path: '/ws/'
    })
    
    // true is default; set to false if you like to use REST
    $feathersProvider.useSocket(true)
  })
  .controller('app', function ($feathers) {
    var userService = $feathers.service('users')

    userService.on('created', function (msg) {
      console.log(msg)
    })

    userService.create({
      username: 'john',
      password: 'unicorn'
    }).then(function (res) {
      $feathers.authenticate({
        type: 'local',
        username: 'john',
        password: 'unicorn'
      }).then(function (result) {
        console.log('Authenticated!', result)
      }).catch(function (error) {
        console.error('Error authenticating!', error)
      })
      console.log(res)
    }).catch(function (err) {
      console.error(err)
    })
  })

Provider-API

  • $feathersProvider.setAuthStorage(newAuthStorage:Object) (default: window.localStorage)
  • $feathersProvider.setSocketOpts(opts:Object) (optional)
  • $feathersProvider.useSocket(socketEnabled:Boolean) (default: true)
  • $feathersProvider.setEndpoint(newEndpoint:String)

Service-Functions (stolen from the official FeatherJS Docs)

  • find({query: {attr: 'value'}}): Retrieves a list of all matching resources from the service
  • get(id, {query: {fetch: 'all'}}): Retrieve a single resource from the service.
  • create({"text": "Example"}): Create a new resource with data which may also be an array.
  • update(id, {"text": "Example"}): Completely replace a single or multiple resources.
    • ProTip: update is normally expected to replace an entire resource which is why the database adapters only support patch for multiple records.
  • patch(id, {"text": "Example"}): Merge the existing data of a single or multiple resources with the new data.
  • remove(id): Remove a single or multiple resources:

ng-feathers's People

Contributors

beevelop avatar bazh avatar greenkeeperio-bot avatar

Watchers

James Cloos avatar Glauber Funez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.