Code Monkey home page Code Monkey logo

737-2023-t1-prac5d's Introduction

ReadMe

This is a node application that uses express.js to provide a basic web server that does simple arithematic operations. Logging is done using the winston library and the application is secured using Passport.


There are two logins available. One for admin and one for user. One sample admin and user has already been added.

Admins can login using this endpoint:

/auth/adminLogin

Users can login using this endpoint:

/auth/userLogin

For both the logins, the request type is POST, and the body should contain the fields:

  1. email
  2. apiKey

The admin credentials are:

username: "[email protected]",
apiKey: "secret"

The user credentials are:

username: "[email protected]",
apiKey: "833b33fca986eebfc320b23f10eaa1de04c36879"

To add a user, login as the admin, using the credentials provided. The application will return a JWT token, which can be used as a Bearer token for additional requests. You can then add a user, using the following POST endpoint:

This will return a randomly generated API key to be given to the user. The user can then use this API key to login using the added username and given API key.

Admins can also fetch all users using this GET endpoint:

/users/getUsers

Users once authenticated can then access the calculator APIs using the JWT token they recieved during login.

The available endpoints are (All are GET requests):

1. /calculate/addtwonumbers?n1=x&n2=y
2. /calculate/subtracttwonumbers?n1=x&n2=y
3. /calculate/multiplytwonumbers?n1=x&n2=y
4. /calculate/dividetwonumbers?n1=x&n2=y

The caclulator microservice runs on port 3030 and can be run by using the command "npm run start".


For running using docker run "docker-compose up --build -d"

737-2023-t1-prac5d's People

Contributors

s221061447 avatar

Watchers

 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.