TL;DR
Serve content with simple webservices. See working example bellow.
Roadie
Roadie is a webserver which serves content via custom created webservices. What set Roadie appart is that not only all contect goes via these webservices but also these webservices are also created and extended via an Object Oriented manner.
Features
- Creation of webservices with nodeJS with an Object Oriented pattern
- Including dynamicly reloading webservices and automaticly recovering from crashes.
- RESTfull routing, accepting wildcards and parameters
- Wildcard routes are translated to regular expressions, this means it is possible to serve files based upon prefix or postfix and extension, see example/routing.json.
- note: Currently it accepts only one wildcard and only at the end of the route
- HTTPS integration
- Possible to include websocket services like ws.
- Support for custom and async route searching
Change log
- 2.3.0 Added async router
- 2.0.0 Changed to Typescript
- 1.0.0 Fixed core lib such that it does not use arguments.caller.callee anymore, this change will ensure compatibility with strict mode and increase performance. (This does mean that all webservices can no longer use
this.inherited()
.) - 0.4.0 Fixed the length calculation where it counts the number of bytes instead of the number of characters.
Routing
Routing is done with a greedy search algoritm, it "searches" the correct route for you via a route table. A good thing to note is that the route is split up in segements, currently these segments are seperated in the url with a "/". This means that you cannot have a parameter surrounded by "/"s and not a wildcard at the end of an url. This will increase the routing with large route tables. Moreover it is easy to add routing features upon.
ToDo
- Add more default webservices such as the staticService
- More routing options with wildcards
Lets do this
See Wiki more details
start.js
"use strict";var $r = ; // create routes by providing a file name containing the routes// or by adding them inlinevar routes = "routing.json" "[GET,POST]/statics/*": "static.js" { // echo the parameters in the search query of the URL ctxresponsedatactxrequestqueryParams; ctxresponse; } ; // HTTP server with (optional) config servervar server = port: 8080 webserviceDir: "webservices/" root: __dirname;var config = server port: 4242 ; // Add the routes to the serverserver; console; serverstart;configstart;
routing.json
webservices/test.js
"use strict";var $r = ; moduleexports = $rWebService;