DailyJS

Node Roundup: Rozu, environmentalist, package.js

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

npm libraries node webapps modules deployment

Node Roundup: Rozu, environmentalist, package.js

Posted by Alex R. Young on .
Featured

npm libraries node webapps modules deployment

Node Roundup: Rozu, environmentalist, package.js

Posted by Alex R. Young on .

Rozu

Rozu (GitHub: avoidwork/rozu, License: BSD-3-Clause, npm: rozu) by Jason Mulligan is a webhook API server that uses io.js or Node, MongoDB, and Redis. MongoDB is used for persistence, and the Redis pub/sub API is used for inbound events.

It's built with tenso for the REST API, and keigai for data storage with MongoDB. It can both send and receive webhook events. To send events, you make a POST to /send with a logged in user, and to make it receive a JSON payload you use /receive. Receiving events uses a token, so it's pretty easy to use it with sites like GitHub.

Once you've installed it you can create an account by making a GET request to /register. If you visit / (whether signed in or not) you'll get a list of API methods.

environmentalist

Alexander Christie has written a blog post about dealing with environmental variables in web applications. Rather than having a list of variables that you have to remember to set on every server for each dependency, his solution is based on using a Node command-line tool called environmentalist (GitHub: AJCStriker/Environmentalist, License: MIT, npm: environmentalist).

The problem is that we use several different packages to build our application, taking full advantage of the awesome NPM private modules that were recently released. The problem was that it has become increasingly hard to keep track of what environmental variables were required to make the project function, or were just generally available, because they were all being accessed at different levels of the applications dependency tree.

With environmentalist, you define a JSON file that specifies each environmental variable:

{
    "name": "PASSWORD_HASH_SECRET",
    "description": "Used to compute the password hash of users",
    "default": "ABCDEFGHIJKLMOP",
    "required": true
}

Because you can include a description it's already useful because in my experience most people export (or heroku config:set) and forget about it later. I also like the fact you can set a default value and the required state. The name is the only required field, so if the values are obvious and self-documenting then you can keep things simple.

When you run environmentalist in the command-line, you'll see a table that shows all of the environmental variables in the current package and its dependencies, which means you can construct projects from submodules with environmentalist JSON files and it'll dig them all out.

package.js

If you've created a Node application but you want to support plugins, what to do you? package.js (GitHub: s-a/package.js, License: MIT and GPL, npm: package.js) by Stephan Ahlf is designed to allow you to open up your project to plugin developers through npm or other package managers.

It allows you to load modules from a set of paths, and then ensure each module has a property (expectedPackageIdentifier) in its package.json. It's a small module with unit tests and an example in the readme.