A barebones Node.js app using Express 4.
This application supports the Getting Started on Heroku with Node.js article - check it out.
These instruction are to help you solve a test challenge "Calculate Square".
This challenge requires you to return the squared of two numbers given an itput.
Create an endpoint /square
that accepts a JSON payload over POST
described below.
Example:
{ "input": 5 }
Example:
25
Make sure you have Node.js installed.
$ git clone https://gitlab.com/ubs-coding-challenge-templates/node-js-template.git # or clone your own fork
$ cd node-js-template
$ npm install
$ npm start
Your app should now be running on localhost:5000.
If you run the following curl
command to send a request to your app, you should be able to see in your logs something like the example below.
$ curl -d '{ "input": 2 }' -H 'Content-Type: application/json' http://localhost:5000/square
Request: POST /square at ...
Request Body:
{
"input": 2
}
Response Body:
4
Response: 200 0.275 ms