Skip to content

API: Created with NodeJs and Express library. JWT is used for RESTful service security and checked in middleware. The project is dockerized and can be hosted easily. 💎

Notifications You must be signed in to change notification settings

alialiayman/Node-MicroService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http://GitHub.com/hackerbay/interview https://github.com/hackerbay/interview-backend-task

Setup

Install Packages

npm i 

Run tests

npm run test

Run locally

npm start

Run docker image

docker build -t aliayman/hackerbay-backend .
docker images
docker run -p 3000:3000 -d aliayman/hackerbay-backend
docker ps
docker logs <container id>
docker exec -it <container id> /bin/bash
exit
docker stop <container id>

DockerHub Image https://hub.docker.com/r/aliayman/hackerbay-backend docker pull aliayman/hackerbay-backend

###Test end points using Curl Login

curl --location --request POST 'localhost:3000/login' \
--header 'Content-Type: application/json' \
--data-raw '{
	"username": "user",
	"password": "pass"
}'
{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXIiLCJleHAiOjE1ODQ5OTY5NzYsImlhdCI6MTU4NDk5MzM3Nn0.JHOdkEAGDdK61rXK66tlM

Apply JSON Patch to a document Use the token generated by login step above in the request below

curl --location --request POST 'localhost:3000/document' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXIiLCJleHAiOjE1ODQ5OTY4MjEsImlhdCI6MTU4NDk5MzIyMX0.eHB5CrTYi6duKkK7-iQ4QJUslAaoan-EHQclOAW-JY0' \
--header 'Content-Type: application/json' \
--data-raw '{
    "doc": {
        "baz": "qux",
        "foo": "bar"
    },
    "patch": [
        {
            "op": "replace",
            "path": "/baz",
            "value": "boo"
        },
        {
            "op": "add",
            "path": "/hello",
            "value": [
                "world"
            ]
        },
        {
            "op": "remove",
            "path": "/foo"
        }
    ]
}'
{"baz":"boo","hello":["world"]}

Create thumbnail

curl --location --request GET 'localhost:3000/thumbnail?url=https://via.placeholder.com/150x150&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXIiLCJleHAiOjE1ODQ5OTY4MjEsImlhdCI6MTU4NDk5MzIyMX0.eHB5CrTYi6duKkK7-iQ4QJUslAaoan-EHQclOAW-JY0' \
--header 'Content-Type: application/json' \
--data-raw '{
    "doc": {
        "baz": "qux",
        "foo": "bar"
    },
    "patch": [
        {
            "op": "replace",
            "path": "/baz",
            "value": "boo"
        },
        {
            "op": "add",
            "path": "/hello",
            "value": [
                "world"
            ]
        },
        {
            "op": "remove",
            "path": "/foo"
        }
    ]
}'
To see an actual png image rendered use post man.

About

API: Created with NodeJs and Express library. JWT is used for RESTful service security and checked in middleware. The project is dockerized and can be hosted easily. 💎

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published