This is a great json server that runs easily with docker compose and you can try or develop it further.🐳
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:
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
4- After that for making sure that project works and connected to db we should create a new user:
make run
Or
go run ./cmd/app/main.go
{
"firstName" : "mahdi",
"lastName" : "dfdf",
"password" : "1234"
}
In psql run:
\connect YOUR_DB_NAME
SELECT * FROM account;
And you should see this response in your terminal:
GET /account -> get all accounts
POST /account -> create new account
GET /account/:id -> get single account
DELETE /account/:id -> delete account
POST /login -> login
{
"firstName" : "mahdi",
"lastName" : "dfdf",
"password" : "1234"
}
{
"number" : BANK_NUMBER,
"password" : "1234"
}
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