Code Monkey home page Code Monkey logo

bankapi's Introduction

bankApi🐿

This is a great json server that runs easily with docker compose and you can try or develop it further.🐳

How to use

1- Make sure you installed docker and docker-compose in your machine.
2- after clone in root project run:

  sudo docker compose up -d

You should see this message in your terminal:
image

After compose your database created based on your config.json in project and docker-compose.yml file(remember you can change or customize it).

3- You can check with this commands below.

  sudo docker exec -it NAME_OF_YOUR_CONTAINER psql -U postgres

Now you connect to postgres user in psql Run:

  \connect YOUR_DB_NAME

For example:
image

4- After that for making sure that project works and connected to db we should create a new user:

Run app

  make run

Or

  go run ./cmd/app/main.go

Create new user

Make a post request: image

  {
    "firstName" : "mahdi",
    "lastName" : "dfdf",
    "password" : "1234"
  }

Check database now

In psql run:

  \connect YOUR_DB_NAME
  SELECT * FROM account;

And you should see this response in your terminal:

Screenshot from 2023-11-05 00-41-02

All endpoints

  GET /account -> get all accounts
  POST /account -> create new account
  GET /account/:id -> get single account
  DELETE /account/:id -> delete account
  POST /login -> login

Create account json data :

  {
    "firstName" : "mahdi",
    "lastName" : "dfdf",
    "password" : "1234"
  }

Login json data :

  {
    "number" : BANK_NUMBER,
    "password" : "1234"
  }

Get single account data :

Parameter : id -> account id in endpoint : /account/[YOUR_BANK_ID]
+ Set the JWT token that you recieved in login response to header with name of "x-jwt-token"

x-jwt-token : YOUR_TOKEN

bankapi's People

Contributors

pooulad avatar

Stargazers

Masoud313 avatar  avatar  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.