TO
tompston/go-rest-api-example
Full-stack example, using JWT, SQLC, Cursor Pagination, Vue 3 and Tailwind
Full-Stack app for creating transactions
vid.mp4
- Backend
- Golang, Chi Framework
- JWT for authentication
- Rate limiting for registration endpoint
- Payload validation using validate package
- Cursor Pagination for Users and Transactions endpoints (using
uuidsandcreated_atvalues) - SQLC for getting the data, dbmate for managing migrations.
- If you want to preview the backend endpoints, just copy
gomarvin.jsoncontent in the editor (Settings -> Import Tab)
- Frontend
- Vue 3 + Vite + Tailwind.
- Registration and Login views
- Field validation errors are returned from the database
- Custom Login error messages if the user does not exist or the password is incorrect
- Home view is guarded by authentication check. If the user has an invalid token, that route is not accessible.
- Other
- Deno and Faker used for seeding the database (using the generated gomarvin client
- Backend code baseline and frontend fetch functions generated with gomarvin.
DISCLAIMER
A lot of parts are rough around the edges and can be improved to avoid code duplication.
- JWT Auth flow in the frontend is lacking
access_tokenexpiration is 15mins, no flow for re-authentication
- DB tables can be improved
- There are endpoints which don't execute any queries.
- Frontend is as minimal as possible
- No loading states while fetching the data
Setup
- Use the db dump to create the db schemas and rows.
- Edit
/backend/.envif needed
# run backend
cd backend
go mod tidy
go mod download
go run main.go
# run frontend
cd frontend
npm i
npm run devOther
# seeder (using deno with faker)
deno run --allow-net ./seeder.ts
# dump database info for test_db
sudo pg_dump -U postgres test_db > ./dump.sqlOn this page
Languages
PLpgSQL37.5%Go23.2%TypeScript14.3%Vue11.9%CSS11.3%Dockerfile0.6%JavaScript0.5%Shell0.4%HTML0.3%
Contributors
Created January 17, 2023
Updated June 13, 2025