Git Product home page Git Product logo

week-10-sanhendrindp's Introduction

Banner

Created by Using

javascript express mongodb nodejs

Link Project

week-10-sanhendrindp-production.up.railway.app/

Project Description

In this week 10 project, we built a RESTful API server using the MongoDB database. This app, later on, can do basic registration for new users and login. Users must have an account by registering and then login. And users will have a role, which is maker and approver. Maker can create a transfer request, but that request will be in pending status first. Then approver can change that status transfer to approved or not approved.

Folders Structure

Here, i will try to explain the structure of important folders for this project by using the image below.

  1. Middleware: This folder serves to store middlewares for this project. It contains 3 files:
    • database-middleware.js : Connection to MongoDB database (linked to Railway).
    • authentication-middleware.js : To authenticate transfer requests by using JWT token. Creating a transfer and getting all transfers will need a token that is obtained when the user login.
    • authorization-middleware : To authorize based on users role, maker or approver.
  2. Routes: This folder serves to set the route for users and transfers, contains 2 files:
    • user-route.js : For login and users register.
    • transfer-route.js : For transfer route.
  3. Controller: This folder contains logic code for folder routes. It contains 2 files:
    • user-controller.js : Logic code for user-route.js
    • transfer-controller.js : Logic code for transfer-route.js
  4. Config: Contain jwt.js to configure JWT token signature.
  5. Docs: Contain openapi.yaml for API documentation which can be run by using Swagger.

Testing All Endpoints Using Postman

  1. POST : /users/register

    For register, users need to input their username and password which is for password needs a minimum length of 8, and should contain alphanumeric. Users need to input their role which is maker or approver.

  2. POST : /users/login

    When users login, they will generate a token that will be used to get all transfer lists and create a transfer request.

  3. POST : /transfers

    By login, users will generate a token, that token can be used for creating a new transfer request. To create a transfer request user needs to input the amount of transfer and information about the transfer.

  4. GET : /transfers

    With token, users also can see all transfers lists.

  5. PUT : /transfer/approve

    When login as approver role, user approver need to input ID transfer and then can update the transfer status created by the user maker to approved or not approved status. But remember, to update the status, user approver needs to input the token that is generated when they login.


    Approve Status by Approver Role




    Transfer Status After Approval


Thank you ๐Ÿ™

week-10-sanhendrindp's People

Contributors

sanhendrindp avatar github-classroom[bot] avatar

Watchers

Alvian Zachry Faturrahman avatar

Forkers

sanhendrindp

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.