The name of database is configurable at dbconfig.yml
createdb echo_demo_dev
go get github.com/rubenv/sql-migrate/...
sql-migrate up
go run server.go
Install Postman and then import api.postman_collection
.
Step 1. Create User Account
curl --request POST \
--url http://localhost:8080/users \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'name=Daniel&email=daniel%40example.com&password=MyPassword'
Step 2. Auth and retrieve JWT Token
curl --request POST \
--url http://localhost:8080/auth \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'email=daniel%40example.com&password=MyPassword'
Step 3. Update User's name with JWT token
curl --request PUT \
--url http://localhost:8080/update_name \
--header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImRhbmllbEBleGFtcGxlLmNvbSJ9.WGtSoCzB6TAOIJED5FWuvGbE_wiI9UVBv4BGHXvW_Og' \
--header 'content-type: application/x-www-form-urlencoded' \
--data name=Daniel%20Lv
- Unit Tests
- Store user with encrypted password
- Add unique index to user's email column and avoid duplicated records
- Authentication user
- Issue JWT token after authentication
- Extract HTTP handler to handler sub-package
- Extract Business logic (e.g. Create User in DB) to service sub-package
- Update User's name (with JWT token)
- Create order for user (with JWT token)
- Introduce a validation framework into application layer
- Deploy to Heroku