A ReSTful Node.js service written in Restify that consumes an addition expression, evaluates it and reports the solution back to the producer.
- Node.js and npm
- Grunt for running tests
- nodemon (optional)
- Clone this repository, or download the source as a .zip archive
cd
into the cloned directory or unzipped archive- install dependencies via npm:
$ npm install
- Create a
.env
file in the project root to set up your local Node environment variable with the following contents:NODE_ENV=local
The only option you may need to configure is the Restify server port, located in settings/local.json
. By default this port is set to 4000
.
To enable logging: $ mkdir logs && touch logs/run.log
- via nodemon:
$ nodemon app.js
- via node:
$ node app.js
With the default settings, the server will be running at: localhost:4000
Simple healthcheck for the service.
Endpoint for consuming an addition expression and reporting the solution back to the producer.
- None
- Status Code: 200
- Response:
{"solution-recorded": true, "expression": "25+65=", "solution": 90}
- Content-Type: JSON
Download, configure and start the Expression-Producer service.
Start the Expression-Consumer service.
Open a browser, hit the /consume endpoint and marvel at the wonders of the addition of random positive integers!
Alternatively, you can also use Postman to view the JSON result returned.
Tests are written BDD-style with Mocha and Supertest and can be run using Grunt: $ grunt test
Benchmarking is available as a Grunt task: $ grunt benchmark
. Results are generated in HTML format and may be found in the /generated/output.html
file, viewable in a web browser.
To run the benchmarks, you must first run the server in test mode:
$ NODE_ENV=test node app.js
then, in a separate terminal tab or window, run the benchmark task:
$ cd to application
$ grunt benchmark
UML diagrams for activity and sequence are located in the ./diagrams
directory:
- expression-consumer-activity.html
- expression-consumer-sequence.html
and are viewable via your web browser.