Giving Back

I’ve been building Restify+Node+MongoDB applications for a little over a year now, and there’s one particular tool that I’ve noticed has been missing.

Problem

One thing that I’ve always needed in all of my applications is the ability to easily validate the requests that clients are sending. It’s fairly common nearly all requests to have different parameters, but there’s nothing in the way of ensuring that certain parameters are present and certain parameters aren’t present. It’s a very basic test you can run at the beginning of every route you write, but it can get very cumbersome to constantly test different values in your requests.

Solution

Lumina is a simple validator that allows you to very easily validate all of your requests without needing to write much code at all. All that’s required to make it work is to specify which keys in the request body are allowed or restricted, and it takes care of making sure that the right errors are sent to the user when they don’t follow the rules.

But the real power isn’t in Lumina’s validation. It’s in its ability to dynamically add steps before specific routes exactly like Restify’s built-in server.use() structure.

Extending

This framework does an excellent job of validating requests for your Restify handlers. It’s equally proficient in preprocessing your routes so that they do anything you can imagine.

Need to prepoulate some objects from your database in a bunch of different requests? Make a handler for it, add the key to your route object, and the handlers will be executed before your application code. This is extremely useful if you’ve got request headers that map to entire datasets (ex. A client API key that maps them to their entire dataset). Populate whatever’s needed.

Need to manipulate request input to clean up certain parameters? Create a handler that does the heavy lifting, and let your Restify handler only contain the actual application logic, rather than all the hairy housekeeping code.

Want to custom manipulate the request query before it gets to your handler? Just add a Lumina method.

Need to test user permission levels before letting them into certain methods? Lumina.

Future

I’m not quite sure that direction I want to take Lumina at this point. It’s currently doing everything it needs to for me. And that’s why I’m open sourcing it. I currently can’t identify what more it needs. So let me know. I just know I don’t want to couple the base pacakge with any database driver, or anything like that. I want those to come as dependents.

Install it, fork it, do whatever with it. But most of all, use it to clean up your code, and build shit faster.

Show your support

Clapping shows how much you appreciated Aleem Haji’s story.