This guide will help you integrate SourceNinja into your node application. This only needs to be done once.
The sourceninja node module can be included in your node application to allow seamless integration with SourceNinja. The sourceninja module will send all of your modules and versions to SourceNinja to begin managing your open source libraries.
Create a SourceNinja account.
Log into SourceNinja and create a product. The product you create will be paired with your application.
After you create a product, you will be directed to a page asking what language your application is running. Select
Node.js from the menu on the left side.
You will be presented with two values, you'll need these two values later.
Install the sourceninja module. You can do this by adding the following line to your
packages.json under dependencies.
Set the environment variables
SOURCENINJA_PRODUCT_ID using the values from step 4. On Heroku, you can use the command
heroku config:add SOURCENINJA_TOKEN=XXX SOURCENINJA_PRODUCT_ID=XXX. If you don't want to pass these parameters as enviroment variables you may pass them programaticly via the kapow function as demonstrated below.
Add the following code above your main function.
var sourceninja = require('sourceninja'); sourceninja.core.kapow(); // You can pass the product ID and token as parameters if you so desire. // sourceninja.core.kapow("477fcfa7-765a-4b91-b6a5-2ebe4c4f9d58", "50a336d92da8ddea1ae0a6c0d06a172");
Now each time you push to production the sourceninja module will report your node modules and versions back to SourceNinja. If you visit your SourceNinja product page you will be given a list of outdated modules.
The SourceNinja data is populated whenever the app is initialized.
If you would like to test sourceninja node module locally, you can call the environement variables before launching your app locally.
SOURCENINJA_TOKEN=XXX SOURCENINJA_PRODUCT_ID=XXX node
Upon doing this, each time you start the node server locally the data will be pushed. You could also use these steps if you want to manage a production instance and a development instance by using a different product_id.
Feel free to email us at support at sourceninja dot com if you have any questions or issues.