valuations-api

module
v0.2.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2023 License: Apache-2.0

README

valuations-api

Api for obtaining and querying vehicle valuations.

Developing locally

TL;DR

cp settings.sample.yaml settings.yaml
docker compose up -d
go run ./cmd/valuations-api

Create DB locally: create database valuations_api with owner dimo;

GRPC Generating client and server code

  1. Install the protocol compiler plugins for Go using the following commands
brew install protobuf
go install google.golang.org/protobuf/cmd/protoc-gen-go
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
  1. Run protoc in the root directory
protoc --go_out=. --go_opt=paths=source_relative \
    --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    pkg/grpc/*.proto

Linting

brew install golangci-lint

golangci-lint run

This should use the settings from .golangci.yml, which you can override.

If brew version does not work, download from https://github.com/golangci/golangci-lint/releases (darwin arm64 if M1), then copy to /usr/local/bin and sudo xattr -c golangci-lint

Make sure you're running the docker image (ie. docker compose up)

If you get a command not found error with sqlboiler, make sure your go install is correct. Instructions here

Local development

Swagger

Generate swagger docs: swag init -g cmd/valuations-api/main.go --parseDependency --parseInternal --generatedTime true

Requirements: go install github.com/swaggo/swag/cmd/swag@latest

Migrations

goose -dir internal/infrastructure/db/migrations create slugs_not_null sql

Run the migrations up: go run ./cmd/valuations-api migrate

Regen the models: sqlboiler psql --no-tests --wipe

Directories

Path Synopsis
cmd
Code generated by swaggo/swag at 2023-09-12 10:06:43.083164 -0400 EDT m=+1.013081001.
Code generated by swaggo/swag at 2023-09-12 10:06:43.083164 -0400 EDT m=+1.013081001.
internal
api
core/commands/mocks
Package mock_commands is a generated GoMock package.
Package mock_commands is a generated GoMock package.
core/services/mocks
Package mock_services is a generated GoMock package.
Package mock_services is a generated GoMock package.
infrastructure/metrics/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
rpc
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL