YANG model-driven Express framework
npm install yang-expressYANG 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-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
``bash`
$ npm install -g yang-expressyang-express
The preferred installation is global for easy access to the 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:
`bash`
$ git clone https://github.com/corenova/yang-express
$ cd yang-express
$ npm install
* Robust model-driven routing
* Hotplug runtime models
* Dynamic interface generators
* Hierarchical (deeply nested) data tree
* Adaptive validations
* Flexibe RPCs and notifications
`bash`
$ yang-express example/example-petstore.yang
The above example will import the example-petstore YANG module andyang-express
start an instance of listening on port 5000 withrestjson feature enabled.
`
Usage: yang-express [options] modules...
Options:
-p, --port
-f, --feature
`
You can run yang-express inside your own project and it willmodules
dynamically import one or more and route them using thefeature plugins specified.
You can also use it as a library module:
`coffeescript`
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.
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.
- Apiary Documentation
- Using YANG with JavaScript
- Using Model API
PetStore is a simple example based on the provided spec sample in the
OpenAPI Specification 2.0
project.
`bash`
$ 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.
- 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/.../ps:pet/...
as well as prefix-qualified . 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.
name | description
--- | ---
restjson | REST/JSON API
openapi | OpenAPI/Swagger 2.0 spec
websocket | socket.io
To run the test suite, first install the dependencies, then run npm
test:```
$ npm install
$ npm test
This software is brought to you by
Corenova Technologies. We'd love to hear
your feedback. Please feel free to reach me at
anytime with questions, suggestions, etc.
[npm-image]: https://img.shields.io/npm/v/yang-express.svg
[npm-url]: https://npmjs.org/package/yang-express
[downloads-image]: https://img.shields.io/npm/dt/yang-express.svg
[downloads-url]: https://npmjs.org/package/yang-express