Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.4.0 #19

Merged
merged 6 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- name: Start Postgresql
run: make db
- name: Run tests
run: go test -v ./...
swagger:
Expand All @@ -41,7 +43,7 @@ jobs:
- uses: actions/checkout@v4
- uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: '1.26.0'
sqlc-version: '1.27.0'
- name: Vet
run: sqlc vet
- name: Diff
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.PHONY: swagger docs
.PHONY: swagger docs db

docs:
swag init --generalInfo cmd/main.go --outputTypes=yaml

swagger:
docker run --detach --name eryth-swagger -p 4000:8080 -e API_URL=/doc/swagger.yaml --mount 'type=bind,src=$(shell pwd)/docs,dst=/usr/share/nginx/html/doc' swaggerapi/swagger-ui

db:
docker compose up --wait db
5 changes: 3 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/crazybolillo/eryth/internal/bouncer"
"github.com/crazybolillo/eryth/internal/handler"
"github.com/crazybolillo/eryth/internal/service"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/cors"
Expand Down Expand Up @@ -56,7 +57,7 @@ func serve(ctx context.Context) error {

conn, err := pgx.Connect(ctx, os.Getenv("DATABASE_URL"))
if err != nil {
slog.Error("failed to establish database connection")
slog.Error("failed to establish database connection", slog.String("reason", err.Error()))
return err
}
defer conn.Close(ctx)
Expand All @@ -73,7 +74,7 @@ func serve(ctx context.Context) error {
}))
r.Use(middleware.AllowContentEncoding("application/json"))

endpoint := handler.Endpoint{Conn: conn}
endpoint := handler.Endpoint{Service: &service.EndpointService{Cursor: conn}}
r.Mount("/endpoints", endpoint.Router())

checker := &bouncer.Bouncer{Conn: conn}
Expand Down
17 changes: 17 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: eryth
services:
db:
image: postgres:15-alpine
ports:
- '54321:5432'
environment:
- POSTGRES_USER=go
- POSTGRES_PASSWORD=go
- POSTGRES_DB=eryth
volumes:
- ./db/migrations/:/docker-entrypoint-initdb.d
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U go" ]
interval: 1s
timeout: 1s
retries: 10
62 changes: 33 additions & 29 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ definitions:
extension:
type: string
type: object
handler.createEndpointRequest:
model.Endpoint:
properties:
accountCode:
type: string
codecs:
items:
type: string
Expand All @@ -31,17 +33,24 @@ definitions:
type: string
maxContacts:
type: integer
password:
type: string
sid:
type: integer
transport:
type: string
type: object
handler.getEndpointResponse:
model.EndpointPage:
properties:
codecs:
endpoints:
items:
type: string
$ref: '#/definitions/model.EndpointPageEntry'
type: array
retrieved:
type: integer
total:
type: integer
type: object
model.EndpointPageEntry:
properties:
context:
type: string
displayName:
Expand All @@ -50,15 +59,17 @@ definitions:
type: string
id:
type: string
maxContacts:
type: integer
sid:
type: integer
transport:
type: string
type: object
handler.listEndpointEntry:
model.NewEndpoint:
properties:
accountCode:
type: string
codecs:
items:
type: string
type: array
context:
type: string
displayName:
Expand All @@ -67,21 +78,14 @@ definitions:
type: string
id:
type: string
sid:
type: integer
type: object
handler.listEndpointsResponse:
properties:
endpoints:
items:
$ref: '#/definitions/handler.listEndpointEntry'
type: array
retrieved:
type: integer
total:
maxContacts:
type: integer
password:
type: string
transport:
type: string
type: object
handler.updateEndpointRequest:
model.PatchedEndpoint:
properties:
codecs:
items:
Expand Down Expand Up @@ -152,7 +156,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/handler.listEndpointsResponse'
$ref: '#/definitions/model.EndpointPage'
"400":
description: Bad Request
"500":
Expand All @@ -169,12 +173,12 @@ paths:
name: payload
required: true
schema:
$ref: '#/definitions/handler.createEndpointRequest'
$ref: '#/definitions/model.NewEndpoint'
responses:
"201":
description: Created
schema:
$ref: '#/definitions/handler.getEndpointResponse'
$ref: '#/definitions/model.Endpoint'
"400":
description: Bad Request
"500":
Expand Down Expand Up @@ -213,7 +217,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/handler.getEndpointResponse'
$ref: '#/definitions/model.Endpoint'
"400":
description: Bad Request
"500":
Expand All @@ -232,7 +236,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/handler.updateEndpointRequest'
$ref: '#/definitions/model.PatchedEndpoint'
"400":
description: Bad Request
"404":
Expand Down
Loading
Loading