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

roadie

v2.3.7

Published

The nodeJs way of deploying webservices

Downloads

65

Readme

Build Status

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 = require("roadie");

// create routes by providing a file name containing the routes
// or by adding them inline
var routes = [
    "routing.json",
    {
        "[GET,POST]/statics/*": "static.js",
        "[GET]/query/": function(ctx) {
            // echo the parameters in the search query of the URL
            ctx.response.data(ctx.request.queryParams);
            ctx.response.send();
        },
    },
];

// HTTP server with (optional) config server
var server = new $r.Server({
    port: 8080,
    webserviceDir: "webservices/",
    root: __dirname,
});
var config = new $r.ConfigServer(server, { port: 4242 });

// Add the routes to the server
server.addRoutes(routes);

console.log(
    "Go to http://localhost:8080/test/{anything}/ or http://localhost:8080/statics/test.html",
);

server.start();
config.start();

routing.json

{
    "[GET]/test/{id}/": "test.js:gId",
    "[GET]/test/hallo/": "test.js:hallo"
}

webservices/test.js

"use strict";
var $r = require("roadie");

module.exports = $r.WebService.extend({
    // Simple webservice returning "HAAY!"
    hallo: function() {
        this.ctx.response.data("HAAY!");
        this.ctx.response.send();
    },
    // Webservice which will return the parameter it got within the URL.
    gId: function() {
        var id = this.ctx.request.parameters.id;
        this.ctx.response.data("got: " + id);
        this.ctx.response.send();
    },
});