Code Monkey home page Code Monkey logo

arithmetic-api's Introduction

Arithmetic Operation API with JWT Authentication

This Node.js application provides a simple arithmetic operation API protected by JWT (JSON Web Tokens) authentication. Clients can perform basic arithmetic operations (addition, subtraction, multiplication, division) on two numbers after authenticating themselves.

Features

  • User authentication using JWT tokens
  • API endpoints for addition, subtraction, multiplication, and division
  • Swagger documentation for easy API reference
  • Refresh token mechanism for obtaining new access tokens

Installation

  1. Clone the repository:

    git clone https://github.com/Duyoofmp/arithmetic-api.git
    
  2. Navigate to the project directory:

     cd arithmetic-api
    
  3. Install dependencies:

    npm install
    

Usage

  1. Start the server: change directory to src folder then:

    node app.js
  2. Access the Swagger documentation by navigating to http://localhost:3000/api-docs in your web browser.

  3. Register a user or use the provided dummy user credentials to authenticate and obtain JWT tokens.

  4. Use the provided JWT token for authorization in API requests to perform arithmetic operations.

API EndPoints

  • Login POST /auth/login - Authenticate and obtain JWT tokens (access token and refresh token).
  • Refresh POST /auth/refresh - Refresh the access token using the refresh token.
  • Addition POST /api/arithmetic/add - Perform addition operation.
  • Subtraction POST /api/arithmetic/subtract - Perform subtraction operation.
  • Multiplication POST /api/arithmetic/multiply - Perform multiplication operation.
  • Division POST /api/arithmetic/divide - Perform division operation.

Dummy User Credentials

```bash
    Username: user
    Password: password

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.