GoJWT is a simple RESTful API built with Go and the Gin framework. It provides basic user authentication functionality, including signup, login, and token validation.
- User signup
- User login
- JWT token generation
- JWT token validation
- Go
- Gin
- PostgreSQL
- Gorm (for database interactions)
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Go (version 1.16 or later)
- PostgreSQL
Clone the repository
git clone https://github.com/yourusername/gopro.git
cd gojwt
Install the dependencies:
go mod download
Set up your environment variables:
Create a .env
file in the root directory of the project, and add the following variables:
PORT=3000
DB="host user=username password=password dbname=dbname sslmode=disable"
JWT="secrettoken"
Replace yourusername
,yourpassword
, and yourdbname
with your PostgreSQL username, password, and database name.
Run the application:
air
API Endpoints
POST /signup
: Register a new user. Body--> email & passwordPOST /login
: Authenticate a user and return a JWT token. Body--> email & passwordGET /validate
: Validate a JWT token.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE.md file for details.