Skip to content

Kshubhranshu/attainU

Repository files navigation


Readme

Software Specification for attainU task.

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage

About The Project

Backend server using Express Framework to :

  • User authentication using jwt
  • User can add address and address data in database
  • User can JSON patching
  • Generate Image Thumbnail

A list of commonly used resources that I find helpful are listed in the acknowledgements.

Built With

This section should list any major frameworks that you built your project using. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites(Linux)

This is an example of how to list things you need to use the software and how to install them.

  • npm
    sudo apt install npm
  • nodejs
    sudo apt-get install nodejs

Installation

  1. Clone the repo
    git clone https://github.com/your_username_/Project-Name.git
  2. Install NPM packages
    npm install
  3. Setup .env
    create a .env file in project directory
    copy environment variables from example-env to .env
    
  4. Start the server
    npm start

Usage

Here is the postman api collention in order to access the api directly from postman postman-api-collection

Public APIs

  1. Authentication
    The api is used for authenticating user with jwt token, the user has to enter his username and password and in response to that a jwt token is generated for the user. The jwt token will be used to access proctected apis.
    
    @POST http://localhost:3000/api/v1/login
     Content-Type: application/json
     {
       "username": "username",
       "password": "pass"
     }
       {
           "success": true,
           "data": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Imt1bWFyIiwiaWF0IjoxNjIxMjU0MzQxLCJleHAiOjE2MjEzNDA3NDF9.   aKpdW6mZYRq7rc3xYXzkO98eDccYfiomH6uMEUZ5_r8"
       }

Protected APIs

NOTE: All protected apis can only be accessed using token which can be generated from above authentication api. The token needs to be passed inside the headers

  1. JSON Patching
    The api is used for creating a patched json. The user need to pass a original json and a path json.
    
    @POST http://localhost:3000/api/v1/pro/add-json-path 
     Co ntent-Type: application/json
     Headers: token: <jwt token>
    
     {
         "original_doc": {
             "baz": "qux",
             "foo": "bar"
         },
         "patch_doc": [
             {
                 "op": "replace",
                 "path": "/baz",
                 "value": "boo"
             },
             {
                 "op": "add",
                 "path": "/hello",
                 "value": [
                     "world"
                 ]
             },
             {
                 "op": "remove",
                 "path": "/foo"
             }]
     }
         {
           "success": true,
           "data": {
                     "patchedDoc": {
                     "baz": "boo",
                     "hello": ["world"]
                     }
                   }
         }
  2. Add user address
  The api is used for storing the address of the user in the database.
 @POST http://localhost:3000/api/v1/pro/add-user-address
 Content-Type: application/json
 Headers: token: <jwt token>
 {
   "address": "address"
 }
 {
   "success": true,
   "data": "Data added successfully"
 }
  1. Generate Image Thumbnail
  The api is used for generating 25x25 thumbnail image from a image url.
 @POST http://localhost:3000/api/v1/pro/create-image-thumbnail
 Content-Type: application/json
 Headers: token: <jwt token>
 {
    "image_url": "https://images.unsplash.com/photo-1585399000684-d2f72660f092?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1051&q=80"
 }
 thumbnail.jpg

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published