Giter Site home page Giter Site logo

attainu's Introduction


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

attainu's People

Watchers

Kumar Shubhranshu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.