Skip to content

AlanSaid1/Fullstack-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BondSwap API

Description

BondSwap is an application for buying and selling bonds. This document provides instructions for configuring and running the application locally.

Requirements

  • Go 1.16+
  • PostgreSQL
  • Git
  • Docker y Docker Compose

Configuration

  1. Clone the repository:

    git clone https://github.com/AlanSaid1/Fullstack-web.git
    cd Fullstack-web
  2. Download the recommended WSL extension for Linux in VSC

  3. Download the Go extension in VSC

  4. If problems exists in Docker Desktop, do the following:

  • Open PowerShell as Admin
  • Run the following command for updates:
wsl --update
  1. Start with the Docker ecosystem:

In the visual studio terminal, run:

docker compose up --build
  1. posible problem: rename the footer component to Footer.tsx

API Endpoints and How to Test Them

User Registration

POST /api/go/users

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:

User Authentication

POST /api/go/login

Description: Authenticates a user and returns a JWT token.

Request Body:

{
  "username": "user",
  "password": "password"
}

**response example **:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Testing in Postman:

Create a bond

POST /api/go/bonds

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.

Get available bonds

GET /api/go/bonds

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:

Get user bonds

GET /api/go/bonds/user

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:

Buy a bond

POST /api/go/bonds/{id_of_bond}/buy

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.

About

A simple app that allow users to have and buy different types of bonds.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published