https://github.com/pooulad/bankapi
🚨Create new project with Go and implement the bank api
https://github.com/pooulad/bankapi
docker go goapi golang json-api json-server
Last synced: 13 days ago
JSON representation
🚨Create new project with Go and implement the bank api
- Host: GitHub
- URL: https://github.com/pooulad/bankapi
- Owner: pooulad
- License: mit
- Created: 2023-11-02T14:30:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-15T09:21:44.000Z (over 1 year ago)
- Last Synced: 2025-03-25T10:37:34.830Z (about 1 month ago)
- Topics: docker, go, goapi, golang, json-api, json-server
- Language: Go
- Homepage:
- Size: 29.5 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```bash
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.
```bash
sudo docker exec -it NAME_OF_YOUR_CONTAINER psql -U postgres
```
Now you connect to postgres user in psql
Run:
```sql
\connect YOUR_DB_NAME
```
For example:
4- After that for making sure that project works and connected to db we should create a new user:
## Run app
```bash
make run
```
Or
```bash
go run ./cmd/app/main.go
```
## Create new userMake a post request:
```json
{
"firstName" : "mahdi",
"lastName" : "dfdf",
"password" : "1234"
}
```
## Check database nowIn psql run:
```sql
\connect YOUR_DB_NAME
SELECT * FROM account;
```
And you should see this response in your terminal:
#### All endpoints
```http
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 :
```json
{
"firstName" : "mahdi",
"lastName" : "dfdf",
"password" : "1234"
}
```## Login json data :
```json
{
"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