

Older versions of Node.js may have compatibility issues with the application.Īdditionally, Travis CI feeds test results to Coveralls, which displays the generator’s code coverage.
YEOMAN INSTALL WEBSTORM GENERATOR
Currently, Travis CI tests the generator against Node.js v4, v5, and v6, as well as IO.js. This should provide an addition level of confidence to the generator’s end-users. Postman provides the ability to individually configure each environment and abstract that environment-specific configuration, such as host and port, from the actual HTTP requests.Īs part of being published to both the npmjs and Yeoman registries, the generator-node-restify-mongodb generator is continuously integrated on Travis CI.

The JSON-formatted response body from the HTTP GET requests should look similar to the output, below.Ī much better RESTful API testing solution is Postman. npm install -g prettyjsonĬurl -X GET -H "Accept: application/json" " -silent | prettyjson curl -X GET -H "Accept: application/json" " For more legible output, try prettyjson. You may test the running application, directly, by cURLing the ‘/widgets’ endpoints. Based on those tests, the application’s code coverage (statement, line, function, and branch coverage) is displayed. Grunt uses the grunt-mocha-istanbul module to execute the same set of jasmine-node tests as shown above. Similarly, the following command displays a code coverage report, using the grunt, mocha, istanbul, and grunt-mocha-istanbul node modules. If the application is running correctly, you should see the following output from the tests. The project contains a set of jasmine-node tests, split between the ‘/widgets’ and the ‘/utils’ endpoints. To test the application, open a separate terminal window, and use the following command. To test the application, using jshint and the jasmine-node module, the sample documents must be imported into MongoDB and the application must be running (see above). The output should be similar to the example, below. To start the application in a new terminal window, use the following command. NODE_ENV=production grunt mongoimport -verbose

If you want to import the sample widget documents into your Test or Production instances of MongoDB, first change the ‘NODE_ENV’ environment variable value. Similar to Yeoman’s Express Generator, this application contains configuration for three typical environments: ‘Development’ (default), ‘Test’, and ‘Production’. NODE_ENV=development grunt mongoimport -verbose Next, import the supplied set of sample widget documents into the local development instance of MongoDB from the supplied ‘data/widgets.json’ file. Yeoman scaffolds the application, creating the directory structure, copying required files, and running ‘npm install’ to load the npm package dependencies. Npm install -g generator-node-restify-mongodb The generator assumes you have pre-installed Node and MongoDB. To begin, install Yeoman and the generator-node-restify-mongodb using npm. Portions of the scaffolded Node application’s file structure and code are derived from what I consider the best parts of several different projects, including generator-express, generator-restify-mongo, and generator-restify. However, while Express is targeted at browser applications, with templating and rendering, Restify is keenly focused on building API services that are maintainable and observable.Īlong with Node, Restify, and MongoDB, theNode application’s scaffolded by the Node-Restify-MongoDB Generator, also implements Bunyan, which includes DTrace, Jasmine, using jasmine-node, Mongoose, and Grunt. This Yeoman generator scaffolds a basic RESTful CRUD API service, a Node application, based on Node.js, Restify, and MongoDB.Īccording to their website, Restify, used most notably by Netflix, borrows heavily from Express. For several recent Node.js projects, I created the generator-node-restify-mongodb Yeoman generator. Yeoman generators reduce the repetitive coding of boilerplate functionality and ensure consistency between full-stack JavaScript projects. Using Yeoman, scaffold a basic RESTful CRUD API service, based on Node, Restify, and MongoDB.
