Skip to content

pooulad/bankApi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

🚨Create new project with Go and implement the bank api

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy