- Install NodeJS, if not installed (Require Node version >= 8.0.0)
$ wget -qO- https://deb.nodesource.com/setup_8.x | bash -
$ sudo apt-get install -y nodejs
- Install npm, if not installed (Require NPM version >= 5.0.0)
$ sudo apt-get install npm
$ sudo npm install -g yarn
-
Install mongodb, if not installed
Install mongo (v4) from here
-
To build the application
$ yarn
- To run the application
$ yarn start
Server will run on http://localhost:3000
URL: http://localhost:3000/get_output
Method: POST
Headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
Payload: {
"roomSize": [5, 5],
"coords": [1, 2],
"patches": [
[1, 0],
[2, 2],
[2, 3]
],
"instructions": "NNESEESWNWW"
}
The response will be like:
{
"coords": [1, 3],
"patches": 1
}
URL: http://localhost:3000/get_records
Method: GET
Headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
The response will be like:
{
data: [
{
"_id": "5d01f6dc3a16821f5559a62d",
"input": {
"roomSize": [5, 5],
"coords": [1, 2],
"patches": [
[1, 0],
[2, 2],
[2, 3]
],
"instructions": "NNESEESWNWW"
},
"output": {
"coords": [1, 3],
"patches": 1
}
}
]
}