BondSwap is an application for buying and selling bonds. This document provides instructions for configuring and running the application locally.
- Go 1.16+
- PostgreSQL
- Git
- Docker y Docker Compose
-
Clone the repository:
git clone https://github.com/AlanSaid1/Fullstack-web.git cd Fullstack-web
-
Download the recommended WSL extension for Linux in VSC
-
Download the Go extension in VSC
-
If problems exists in Docker Desktop, do the following:
- Open PowerShell as Admin
- Run the following command for updates:
wsl --update
- Start with the Docker ecosystem:
In the visual studio terminal, run:
docker compose up --build
- posible problem: rename the footer component to Footer.tsx
Description: Registers a new user in the system.
Request Body:
{
"username": "new_user",
"password": "secure_password",
"email": "email@example.com"
}
**response example **:
{
"id": 1,
"username": "new_user",
"email": "email@example.com"
}
Testing in Postman:
- Select the POST method.
- Enter the URL: http://localhost:8080/api/go/users.
- In the Body tab, select raw and JSON.
- Enter the JSON request body.
- Click Send.
Description: Authenticates a user and returns a JWT token.
Request Body:
{
"username": "user",
"password": "password"
}
**response example **:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Testing in Postman:
- Select the POST method.
- Enter the URL: http://localhost:8080/api/go/login.
- In the Body tab, select raw and JSON.
- Enter the JSON request body.
- Click Send.
Description: Creates a new bond.
Request Body:
{
"name": "Example Bond",
"number": 100,
"price": 1000.00,
"currency": "MXN"
}
**response example **:
{
"id": 1,
"name": "Example Bond",
"number": 100,
"price": 1000.00,
"currency": "MXN",
"seller_id": 1
}
Testing in Postman:
- Select the POST method.
- Enter the URL: http://localhost:8080/api/go/bonds.
- In the Body tab, select raw and JSON.
- Enter the JSON request body.
- In the Headers tab, add a key Authorization with the value Bearer <your_token>.
- Click Send.
Description: Retrieves the list of available (unsold) bonds.
**response example **:
[
{
"id": 1,
"name": "Example Bond",
"number": 100,
"price": 1000.00,
"currency": "MXN",
"seller_id": 1,
"buyer_id": null
}
]
Testing in Postman:
- Select the GET method.
- Enter the URL: http://localhost:8080/api/go/bonds.
- Click Send.
Description: Retrieves the list of bonds owned by the authenticated user.
**response example **:
[
{
"id": 1,
"name": "Example Bond",
"number": 100,
"price": 1000.00,
"currency": "MXN",
"seller_id": 1,
"buyer_id": 2
}
]
Testing in Postman:
- Select the GET method.
- Enter the URL: http://localhost:8080/api/go/bonds/user.
- In the Headers tab, add a key Authorization with the value Bearer <your_token>.
- Click Send.
Description: Buys an available bond.
**response example **: No Content (204)
Testing in Postman:
- Select the POST method.
- Enter the URL: http://localhost:8080/api/go/bonds/{id}/buy (replace {id} with the ID of the bond to buy).
- In the Headers tab, add a key Authorization with the value Bearer <your_token>.
- Click Send.