Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tompston/go-rest-api-example
Full-stack example, using JWT, SQLC, Cursor Pagination, Vue 3 and Tailwind
https://github.com/tompston/go-rest-api-example
cursor-pagination go jwt-authentication postgresql rest-api sqlc tailwind typescript vue
Last synced: 19 days ago
JSON representation
Full-stack example, using JWT, SQLC, Cursor Pagination, Vue 3 and Tailwind
- Host: GitHub
- URL: https://github.com/tompston/go-rest-api-example
- Owner: tompston
- Created: 2023-01-17T22:25:13.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-19T20:10:37.000Z (almost 2 years ago)
- Last Synced: 2024-10-02T09:14:18.433Z (about 1 month ago)
- Topics: cursor-pagination, go, jwt-authentication, postgresql, rest-api, sqlc, tailwind, typescript, vue
- Language: PLpgSQL
- Homepage:
- Size: 162 KB
- Stars: 17
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-golang-repositories - go-rest-api-example - stack example, using JWT, SQLC, Cursor Pagination, Vue 3 and Tailwind (Repositories)
README
## Full-Stack app for creating transactions
https://user-images.githubusercontent.com/82293948/213549059-0cdc7ddc-fabe-4d7f-92c3-1844c08ccbb5.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 `uuids` and `created_at` values)
- SQLC for getting the data, dbmate for managing migrations.
- If you want to preview the backend endpoints, just copy `gomarvin.json` content in the [editor](https://gomarvin.pages.dev/) (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_token` expiration 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/.env` if needed```bash
# run backend
cd backend
go mod tidy
go mod download
go run main.go# run frontend
cd frontend
npm i
npm run dev
```#### Other
```bash
# 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.sql
```