modulepackage
0.0.0-20240628122416-55ef94975374
Repository: https://github.com/iamriteshkoushik/go-bank.git
Documentation: pkg.go.dev
# README
Overview
Simple HTTP-REST API written in Go using Gorilla/Mux, PostgreSQL and JWT Auth.
Setup
Clone the project and run the corresponding commands
# Cloning
git clone https://github.com/IAmRiteshKoushik/go-bank
# Fetching all required dependencies
go mod tidy
go mod vendor
# Compiling and the project
make build
# Seeding with sample data : use the --seed flag
# Seed data : { FName: Ritesh, LName: Koushik, Password: hello123 }
./bin/go-bank --seed
# Running the project
make run #(or)
./bin/go-bank
All further testing can be run through Postman, cURL, ThunderClient etc.
Run Locally
Create the environment variables file
touch .env
Setup the environment variables
# Inside the .env file, have the following KV pairs
DATABASE_URL="<your-database-connection-string-here>"
JWT_SECRET="<your-jwt-secret-here>"
Have the database running. You can either have your local installation of PostgreSQL, a cloud provider like Neon or a docker container. It is advisable to use a cloud provider because it comes with a table visualization studio.
Testing
The test suite an be run as follows
make test
The following endpoints can be tested
POST : http://localhost:3000/login # Log in and receive JWT token
GET : http://localhost:3000/account # Fetching all acc details
POST : http://localhost:3000/account # For creating acc
GET : http://localhost:3000/account/{id} # Fetching particular acc details
DELETE : http://localhost:3000/account/{id} # Deleting particular acc
POST : http://localhost:3000/transfer # Transfering money to an account
The header and body requirements of the endpoints can be found from the
types.go
file. Will share a link to the Postman collection later.
# Functions
No description provided by the author
Creating new API server.
No description provided by the author
-- Helper Functions Creating resopnse JSONs.
# Structs
Struct tags will effectively tell the program that if this struct gets serialized into a JSON then how the field names are going to be.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
# Type aliases
No description provided by the author