A simple go REST service to show implementation of PostgreSQL, CI/CD, Open ID Connect, testing, deployment
- create a postgresql db locally
- Use
DATABASE_URLenv var to reference it - run
make migrateupto create tables - run
make migratedowmto remove tables
- run
$ make serverto start the application
- Set up open api by following this guide
- test
/loginand/logoutroutes on this app to ensure everything is working - Note a
/callbackroute on this app checks whether a user has an account in this system before saving them
- go to Africa's Talking sandbox and create an API key for the app
- you can launch a simulator with the target phone numbers you will use in your app
-
use the following commands to run tests
-
$ make test -
$ make testcover -
$ make testview
- use
GET /loginto get the redirect url for login - open
redirecturl from login response and you will be prompted to log in by OAuth
- go to
GET /auth/profileto get the profile information of current user, for a new user, thestatusisinactiveuntil they have onboarded - use
POST /auth/onboardto update phone number and username. If you don't update your phone number, or if yourstatusis notactiveyou wont be able to make orders
- use
POST /auth/item(will require admin account in future) to add items to order - use
GET /auth/item(will require pagination in future) to view all items - use
DELETE /auth/item/{id}(will require admin account in future) to delete an item
- use
POST /auth/ordersand enter the item id in the body to order an item - go to Africa's talking and ensure you received an SMS
- go to
GET /auth/currentuser/ordersto view orders of currently logged in user - go to
GET /auth/ordersto get all orders ever made (Pagination and admin o=implementation required in future)
- go to
POST /logoutto log out of the application - all routes with
*/auth/*should give an error 401 when you try accessing them when you are not logged in