An API server built with Node to demonstrate jwt, json patching and thumbnail generation.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Inside the project directory, run
npm install
to install required dependencies.
This application requires a secret to work well, on your project directory:
- Create an env file
- Inside .env file, type the following :
SECRET="<secret>"
N/B: Replace secret with any text of your choice
To start the API server run
npm start
You can then start making requests via postman.
To test the application on your local machine, run
npm test
To test the application with code-coverage, run
npm test-with-coverage
A code coverage report will be seen on your console.
You can a new user login by sending a POST request to https://localhost:3000/api/login Request body should contain username and password; the API will return a token for the user which will be used for future requests to the server. Note: Any username/password combination is accepted
This endpoint accepts two parameters (document and patch) which are JSON objects. Send a PATCH request to https://localhost:3000/api/patch?token=validToken and the API will return a valid patched JSON object. Note: Replace validToken with the token gotten from the login for authentication
This endpoint accepts an image url, generates a 50x50 thumbnail image and returns it to the user. Send a GET request to https://localhost:3000/api/thumbnail?img=ImageUrl&token=validToken Note: Replace imgUrl with the url of the image and validToken with the token gotten from the login for authentication
- Mocha - For automated tests.
- Istanbul - For test coverage.
- jwt - Token generation and verification.
- node-thumbnail - Fast thumbnail generation in Node.
- should - Expressive assertion library.
- supertest - High level HTTP tests.
- Ibe Ogele - ibesoft11