Giter VIP home page Giter VIP logo

arief-rohman-betest's Introduction

Arief Rohman BE Test

Simple REST Api using express, mongodb and redis.

Support Node >= 18

Installation

  • clone this repo
  • run npm install to install dependencies
  • copy .env.example file into .env file and provide the value with your setup
  • run npm start to run the server

Authentication

POST /oauth/register

request:
  Content-Type: application/json
  Body: {
    "username": "yourusername"
  }

response:
  201 Created
  Content-Type: application/json
  Body: {
    "token": "access token"
  }

  400 Bad Request
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}
POST /oauth/token

request:
  Content-Type: application/json
  Body: {
    "username": "yourusername"
  }

response:
  200 OK
  Content-Type: application/json
  Body: {
    "token": "access token"
  }

  400 Bad Request
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

Endpoints

GET /ping

response:
  200 OK
  Content-Type: text/plain
  pong
GET /v1/user/accountNumber/:accountNumber

request:
  Authorization: Bearer <access token>

response:
  200 OK
  Content-Type: application/json
  Body: {
    "userName": "username",
    "accountNumber": "123456",
    "emailAddress": "[email protected]",
    "identityNumber": "654321",
    "id": "userid"
  }

  404 Not Found
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

  401 Unauthorized
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

  400 Bad Request
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}
GET /v1/user/identityNumber/:identityNumber

request:
  Authorization: Bearer <access token>

response:
  200 OK
  Content-Type: application/json
  Body: {
    "userName": "username",
    "accountNumber": "123456",
    "emailAddress": "[email protected]",
    "identityNumber": "654321",
    "id": "userid"
  }

  404 Not Found
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

  401 Unauthorized
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

  400 Bad Request
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}
POST /v1/user

request:
  Content-Type: application/json
  Authorization: Bearer <access token>
  Body: {
    "userName": "username",
    "accountNumber": "123456",
    "emailAddress": "[email protected]",
    "identityNumber": "654321"
  }

response:
  201 Created
  Content-Type: application/json
  Body: {
    "message": "User created",
    "user": {
      "userName": "username",
      "accountNumber": "123456",
      "emailAddress": "[email protected]",
      "identityNumber": "654321",
      "id": "userid"
    }
  }

  401 Unauthorized
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

  400 Bad Request
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}
PATCH /v1/user/:userId

request:
  Content-Type: application/json
  Authorization: Bearer <access token>
  Body: {
    "userName": "username",
    "emailAddress": "[email protected]"
  }

response:
  200 OK
  Content-Type: application/json
  Body: {"message":"User updated"}

  404 Not Found
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

  401 Unauthorized
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

  400 Bad Request
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}
DELETE /v1/user/:userId

request:
  Authorization: Bearer <access token>

response:
  200 OK
  Content-Type: application/json
  Body: {"message":"User deleted"}

  404 Not Found
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

  401 Not Authorized
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

  400 Bad Request
  Content-Type: application/json
  Body: {"message":"error message","errors":["error message"]}

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.