npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yang-express

v2.1.9

Published

YANG model-driven Express framework

Downloads

186

Readme

yang-express

YANG model-driven Express framework

Minimalistic web framework leveraging powerful YANG schema expressions according to RFC 6020. Generates dynamic model-driven interfaces with flexible plugin system.

NPM Version NPM Downloads

Installation

$ npm install -g yang-express

The preferred installation is global for easy access to the yang-express utility but can also be used as a dependency module to enable YANG model-driven express app as part of your project.

For development/testing, clone from repo and initialize:

$ git clone https://github.com/corenova/yang-express
$ cd yang-express
$ npm install

Features

  • Robust model-driven routing
  • Hotplug runtime models
  • Dynamic interface generators
  • Hierarchical (deeply nested) data tree
  • Adaptive validations
  • Flexibe RPCs and notifications

Quick Start

$ yang-express example/example-petstore.yang

The above example will import the example-petstore YANG module and start an instance of yang-express listening on port 5000 with restjson feature enabled.

  Usage: yang-express [options] modules...

  Options:
      -p, --port <number>    Run yang-express on <port> (default: 5000)
      -f, --feature <name>   Enable one or more features: (restjson, openapi, etc.)

You can run yang-express inside your own project and it will dynamically import one or more modules and route them using the feature plugins specified.

You can also use it as a library module:

require 'yang-js'
opts =
  port: 5000
  feature: [ 'restjson', 'openapi' ]
  modules: [ 'ietf-yang-library' ]
express = require('yang-express').eval()
express.in('run')
  .invoke opts
  .then  (res) -> console.log "running"
  .catch (err) -> console.error err

For more information on programmatic usage, be sure to take a look at the References listed below.

References

This module is a YANG model-driven data module, which is essentially a composition of the YANG Schema and Control Binding. It is designed to model middleware routing runtime configuration and can be utilized with or without an actual Express instance.

Examples

PetStore is a simple example based on the provided spec sample in the OpenAPI Specification 2.0 project.

$ npm run example:petstore

When the yang-express app runs, it will auto-generate the data model using the example-petstore.yang schema and dynamically route the following endpoints utilizing the restjson dynamic interface generator:

endpoint | methods | description --- | --- | --- /pet | CRUMDO | operate on the pet collection /pet/:id | RUMDO | operate on a specific pet /pet/:id/:leaf | RUMDO | operate on a pet's attribute /pet/:leaf | RUMDO | bulk operate attributes*

This example runs using the sample data found inside the config directory.

CRUMDO

  • C: CREATE (POST)
  • R: READ (GET)
  • U: UPDATE (PUT)
  • M: MODIFY (PATCH)
  • D: DELETE
  • O: OPTIONS

Alternative API endpoints can be fully-qualified /petstore:pet/... as well as prefix-qualified /ps:pet/.... This is the suggested convention when using multiple models that may have namespace conflict (if mounted together at '/').

Note: Bulk operation on all matching attributes can be used to set a new value for every matching attribute in the collection.

Dynamic Interface Generators

name | description --- | --- restjson | REST/JSON API openapi | OpenAPI/Swagger 2.0 spec websocket | socket.io

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

License

Apache 2.0

This software is brought to you by Corenova Technologies. We'd love to hear your feedback. Please feel free to reach me at [email protected] anytime with questions, suggestions, etc.