Skip to content

Repository files navigation

RestBundle (MOVED...)

Simplify REST API creation and maintentance with re-usable REST bundles. Encapsulate related REST services in a single JavaScript class that extends RestBundle.

Example: Define a REST bundle comprising a single resource (i.e., /greeting/hello) with handlers for GET and POST:

classHelloRestextendsRestBundle{constructor(name="greeting",options={}){super(name,options);varhandlers=[this.resourceMethod("get","hello",this.getHello,"text/html"),this.resourceMethod("post","hello",this.onDie),];Object.defineProperty(this,"handlers",{value: handlers,});}getHello(req,res){return"hello";}postHello(req,res){thrownewError("goodbye");}}

Add HelloRest to a nodejs application:

constHelloRest=require("../test/hello-rest");varhelloRest=newHelloRest("greeting");helloRest.bindExpress(app);

Launch web server:

npmstart

A RestBundle can be shared for use by others as an npm package.

Vue 2

RestBundle relies on Vue.js for modular web components.

  1. npm run dev
  2. http://localhost:4000/greeting/ui

About

Javascript base class for a REST resource bundle that can be easily bound into a nodejs express service as a replaceable component. A RestBundle can be deployed as an npm package to extend multiple independent REST services.

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages