An implementation of the sample petstore application from the examples in oapi-codegen
- Run
docker build -t petstore .
to compile a docker image of the application - Run
docker-compose up -d
in the root of the repo - The application will now be available at localhost:5000
- Run
./migrate.sh create <migration_name>
to create your new migration scripts - Fill in the new migration scripts created under
sql/migrations
- Regenerate go code for interacting with the database using
generate-code.sh
- All schema migrations will be performed automatically whenever the application starts
- Make your updates to the openapi spec in openapi/openapi.yaml
- Generate go code using
generate-code.sh
- The newly generated interfaces for API endpoint handlers will be in
pkg/api/controller.go
- Update
sql/queries/queries.sql
to add your new queries, or add additional files in the same directory - Regenerate go code for interacting with the database using
generate-code.sh
- The newly generated query functions will be in
pkg/db/queries.sql.go
Run the run-integration-tests.sh
script. This script performs the following steps:
- It builds a new docker container for the application
- It brings up (or recreates) all containers using docker compose
- It waits for the application to become healthy
- It runs all integration tests (defined in the
integrationtests
directory)
- Add unit tests
- Add pipeline logic to build / test / upload the application container on every master commit
- Add pipeline logic to deploy the application to the cloud on every master commit
- Expand the scope of the application, so there are multiple tables and queries with joins
- Fork this repo and make something actually useful