A Microservice with 2 main functions of patching JSON and generating thumbnail.
This project requires nodejs installed on your local machine.
The following instructions would get this project up and running on you local machine for development and testing purpose
mkdir project-directory
cd project-directory
git clone https://github.com/kennyose/hackerbay-backend
cd project-directory
# run the command
npm install
project-directory
├── node_modules
├── public
│ └── css
│ │ └── style.css
│ └── js
│ └── custom.js
├── src
│ └── app.js
│ └── controllers.js
│ └── index.js
│ └── middleware.js
│ └── routes.js
| └── utils.js
├── test
│ └── index.test.js
├── views
│ └── error.ejs
│ └── errorPage.ejs
│ └── index.ejs
│ └── login.ejs
├── .dockerignore
├── .editorconfig
├── .env
├── .gitignore
├── access.log
├── Dockerfile
├── LICENSE.md
├── .package-lock.json
├── .package.json
├── README.md
- Create a .env file
- write your secret
JWT_SECRET=yoursecret
npm start
Open http://localhost:8080 to view it in the browser.
- Don't forget to hardcode a resently signed jwt token for use in
index.test.js Ln 9 Col 1
while testing.
npm test
npm run cover
This Project uses EsLint for coding guide
This Project is built with:
- NodeJS - Javascript runtime engine
- ExpressJS - Web Server Framework
- Chai and chaiHttp - Unit test
- POST http://localhost:8080/login:
- Request - username and password in body of request.
- Response - a JSON containing signed JWT under token.
- POST http://localhost:8080/patch:
- Request - json[should be an object] and patch[should be an array of object(s) containing op, path & value] both strigified in body of request.
- Response - a JSON containing result of patch operation under patchedObj
- POST http://localhost:8080/thumbnail:
- Request - url[containing a URI of public image] in query of request.
- Response - a binary data in chunks.
- Make sure you have Docker installed Locally
- DockerHub - Pull this project docker image by running this command
docker pull kennyose/hackerbay-node
- Check container's image id by running
$ sudo docker ps -l
- Start project in docker container by running
$ sudo docker run -p 8080:8080 -it ${IMAGE}
- replace ${IMAGE} with container's image id.
- Test - JWT is unable to sign when testing,
- Fix - expose process.env.JWT_SECRET in
controller.js Ln 27 Col 31
and inmiddleware.js Ln 9 Col 25
- Fix - expose process.env.JWT_SECRET in