Car Resources API app built in NodeJS, Express, Chai, Mocha and Axios.
Different babel configurations are provided in bin
directory for dev and prod app environments
For development, you will only need Node.js, express and a node global package, NPM, installed in your environement.
There is one environment variable needed to be set. It is `MONGODB_CONN'. Its value can be requested or sent via email.
$ git clone https://github.com/fahadmajeed/ecs.git
$ cd ecs
$ npm install
App uses Mocha, Chai for unit tests and Supertest for integration tests.
To run tests
on commandline run npm run test
All tests are defined in test
directory
$ npm run start
##Production run instructions For production environment on cloud or server in a containerized environment. Following command can be configured
$ npm run production
Gets a list of cars.
App by default runs on port 3000 so making a GET request to http://localhost:3000/api/v1/cars
would return response in following
structure:
You can use Postman client or fire up browser at following URL to see the response.
response
[
{
"_id": "5e4a6e3f166de844543338ca",
"make": "BMW",
"model": "7 Series",
"colour": "Silver",
"year": "2011",
"words": "queries ceres theories wearies sheer ease",
"__v": 0
},
{
"_id": "5e4a6e46166de844543338cb",
"make": "BMW",
"model": "7 Series",
"colour": "White",
"year": "2012",
"words": "queries ceres theories wearies sheer ease",
"__v": 0
}
]
Gets one existing car info
Creates a new car. body of request has to have at least following 3 properties
{
"make": "BMW",
"model": "7 Series",
"year": "2011",
}
Updates existing car. body of request has to have at least following 4 properties including ID i.e, '_id'
{
"_id": "5e4a6e3f166de844543338ca"
"make": "BMW",
"model": "7 Series",
"year": "2011",
}
Deletes existing car. Request param is the ID of the car you want to delete