Socket
Socket
Sign inDemoInstall

siren-builder

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    siren-builder

A fluent Siren hypermedia representation builder.


Version published
Weekly downloads
373
increased by0.27%
Maintainers
1
Install size
63.2 kB
Created
Weekly downloads
 

Readme

Source

node-siren-builder

A fluent Siren hypermedia representation builder.

const Siren = require('siren-builder');

const entity = Siren.entity()
  .addClass('home')
  .addProperty('version', '2.4.1')
  .addProperty('health', 'green')
  .addAction('find-widget', Siren.action()
    .setTitle('Find Widget')
    .setMethod('GET')
    .setHref('https://api.example.org/widgets/search')
    .setType('application/x-www-form-urlencoded')
    .addField('q', Siren.field()
      .setType('text')))
  .addLink('self', Siren.link()
    .setHref('https://api.example.org/'));

const siren = entity.toJSON();

// siren = {
//   class: ['home'],
//   properties: {
//     version: '2.4.1',
//     health: 'green'
//   },
//   actions: [
//     {
//       name: 'find-widget',
//       method: 'GET',
//       href: 'https://api.example.org/widgets/search',
//       title: 'Find Widget',
//       type: 'application/x-www-form-urlencoded',
//       fields: [
//         {
//           name: 'q',
//           type: 'text'
//         }
//       ]
//     }
//   ],
//   links: [
//     {
//       rel: ['self'],
//       href: 'https://api.example.org/'
//     }
//   ]
// }

Installation

$ npm install siren-builder

API

API Documentation

Alternatives

If you are not building Siren representations imperatively and are able to specify them in one expression, you may prefer to use node-siren-writer for syntactic brevity.

Keywords

FAQs

Last updated on 08 Mar 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc