NodeJS Module Tutorial: A New Series
Recently at work we’ve been busy working on a number of security projects. One of the key projects is having our user directory accessible universally which means LDAP. So we’ve undertaken moving our “Directory of Truth” from Okta to JumpCloud. While Okta provides a good product, JumpCloud provides LDAP-as-a-Service (and RADIUS-as-a-service) which has worked very well in my testing so far. What does this have to do with writing a nodeJS module? Well, JumpCloud has a lovely REST API and had no NPM module.
Okta has a REST API and
an npm module available for use. However since JumpCloud lacked an npm module, I was on my own for an interface. After writing the first version I realized the code was halfway decent and could be useful for a module. I had no idea how to write a node module so I embarked upon learning all the different bits and pieces as I went. There was no single document I used, so I figured it was worth writing something for those future coders who think writing a module is “hard” (hint: It’s really not).
This tutorial series will be broken down into a number of posts, each covering a different step in the process of building a full (and community friendly) node module.
- Turning functions into module patterns
- README’s for everyone
- Writing tests
- Using Travis CI
- Publishing code to npm
The examples from this tutorial will be based off the jumpcloud module now available on npm. You can also find the code on github under jumpcloud-node. If there are any areas of module use that you think I’ve forgotten to cover, please let me know and I’ll see what I can do.