Skip to content

ankorstore/yokai-petstore-demo

Repository files navigation

Yokai Petstore Demo

License: MIT Go version

HTTP application demo based on the Yokai Go framework.

Overview

This demo provides a REST API example, with:

Layout

This demo is following the recommended project layout:

  • cmd/: entry points
  • configs/: configuration files
  • db/
    • migrations/: SQL migrations files for gomigrate
    • queries/: SQL queries files for sqlc stubs generation
    • sqlc/: sqlc generated stubs
  • internal/:
    • handler/: HTTP handlers
    • module/:
      • fxdatabase: database/sql + gomigrate module
      • fxsqlc: sqlc module
    • bootstrap.go: bootstrap
    • register.go: dependencies registration
    • router.go: routing registration
  • sqlc.yaml: sqlc configuration

Makefile

This template provides a Makefile:

make up              # start the docker compose stack
make down            # stop the docker compose stack
make logs            # stream the docker compose stack logs
make fresh           # refresh the docker compose stack
make sqlc            # regenerate sqlc stubs
make migrate-create  # create migration
make migrate-up      # apply all migrations 
make migrate-down    # revert all migrations 
make test            # run tests
make lint            # run linter

Usage

Start the application with:

make fresh

Then apply database migrations with:

make migrate-up

Once ready, the application will be available on:

Available endpoints on http://localhost:8080:

Route Description
[GET] /owners List all owners
[POST] /owners Create an owner
[GET] /owners/:id Get an owner
[DELETE] /gophers/:id Delete an owner

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published