drupal-services

0.2.1 • Public • Published

Drupal Services

A pretty simple promise-based wrapper for using the Drupal 7 Services 3.x API. Request and response uses JSON.

Handles session cookie, user token and x-csrf headers.

Usage

NOTE Major API changes in this version!!

Coffeescript example:

{Service} = require 'drupal-services'
 
endpoint =
    protocol: 'https'
    auth: 'user:password'
    hostname: 'apiserver.com'
    pathname: '/myendpoint'
 
service = new Service endpoint
 
# Query node resource
service
.index '/node'
.then (results) ->
    console.log results
 
# If user needs to be logged in, using factory method:
Service
.factory endpoint
.login 'user', 'password'
.then (user) ->
    # Retreive a node
    service.retreive 'node', 1
 
.then (node) ->
    console.log node
 

Todo

I still need to write some more tests :)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.1
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.1
    2
  • 0.2.0
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i drupal-services

Weekly Downloads

4

Version

0.2.1

License

MIT

Last publish

Collaborators

  • elrolito