Go Todo application with user registration with JWT and SMS OTP.
- Go + Gin
- Templ
- HTMX
- MySQL
- more go tools...
- Go programming language installed on your system
- MySQL or another compatible database installed and running
.env
file containing environment variables (e.g., database connection details, server port)
- Clone this repository to your local machine:
git clone https://github.com/Kei-K23/go-otp.git
- Navigate to the project directory:
cd go-otp
- Create a .env file in the project root and add the following environment variables:
JWT_SECRET_KEY=<YOUR_JWT_SECRET_KEY>
DB_CONNECTION=<YOUR_DB_CONNECTION>
SENDER=<YOUR_TWILIO_SENDER_NUMBER>
TWILIO_AUTH_TOKEN=<YOUR_TWILIO_AUTH_TOKEN>
TWILIO_ACCOUNT_SID=<YOUR_TWILIO_ACCOUNT_SID>
- Install dependencies:
go mod tidy
- Run migration
make migration
- Push database table
make migrate-up
- Run server
make run
This will serve the server at http://localhost:8080
- Access the API endpoints using tools like cURL or Postman.
All endpoints are available under http://localhost:4000/api/v1
. Make sure prefix with your localhost with /api/v1
.
Authentication
POST /register
: Register pagePOST /login
: Login pagePOST /verify
: Verify page
Below defined endpoints are protected with JWT authentication. Make sure valid JWT token exist in bearer authentication header
Users
GET /users
: User page