Skip to content

Commit

Permalink
wip: prefix apis
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie committed Mar 5, 2024
1 parent 8e97684 commit c924ba5
Show file tree
Hide file tree
Showing 101 changed files with 166 additions and 11,015 deletions.
10 changes: 10 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# .air.toml
root = "."
tmp_dir = "tmp"
[build]
cmd = "go build -o ./tmp/main cmd/api/main.go"
bin = "./tmp/main"
delay = 1000 # ms
exclude_dir = ["assets", "tmp", "vendor"]
include_ext = ["go", "tpl", "tmpl", "html"]
exclude_regex = ["_test\\.go"]
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
# Output of the go coverage ctool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
tmp

# Go workspace file
go.work
Expand Down
12 changes: 8 additions & 4 deletions api/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ info:
description: |
# Introduction
The Typhoon API allows you to NATS.io
Typhoon is an event bridge for applications and services.
license:
name: Apache 2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'

servers:
- url: http://localhost:8080
- url: /v1

tags:
- name: System
description: |-
These are the NATS.io that are managed by Typhoon.
These are the system managed by Typhoon.
- name: Team
- name: Server
description: |-
These are the teams that are using Typhoon.
- name: Triggers
description: |-
These are the triggers that are used to send events to Typhoon.
consumes:
- "application/json"
Expand Down
4 changes: 2 additions & 2 deletions api/config.client.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package: api
package: apis
generate:
client: true
output: api/client.gen.go
output: pkg/apis/client.gen.go
output-options:
skip-prune: true
4 changes: 2 additions & 2 deletions api/config.models.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package: api
package: apis
generate:
models: true
embedded-spec: true
output: examples/api/models.gen.go
output: pkg/apis/models.gen.go
output-options:
skip-prune: true
4 changes: 2 additions & 2 deletions api/config.server.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package: api
package: apis
generate:
fiber-server: true
strict-server: true
output: api/server.gen.go
output: pkg/apis/server.gen.go
output-options:
skip-prune: true

Expand Down
18 changes: 0 additions & 18 deletions api/sources/register.go

This file was deleted.

21 changes: 6 additions & 15 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import (
"log"
"os"

"github.com/zeiss/typhoon/internal/adapter"
"github.com/zeiss/typhoon/internal/adapter/handlers"
"github.com/zeiss/typhoon/internal/config"
"github.com/zeiss/typhoon/internal/controllers"
"github.com/zeiss/typhoon/internal/services/api"
"github.com/zeiss/typhoon/internal/api/adapter"
"github.com/zeiss/typhoon/internal/api/config"
"github.com/zeiss/typhoon/internal/api/services"

"github.com/katallaxie/pkg/logger"
"github.com/katallaxie/pkg/server"
Expand Down Expand Up @@ -60,18 +58,11 @@ func run(ctx context.Context) error {
return err
}

db := adapter.NewDB(conn)
// db := adapter.NewDB(conn)
srv, _ := server.WithContext(ctx)

teamsCtrl := controllers.NewTeamsController(db)

h := adapter.NewHandlers(
handlers.NewTeamsHandler(teamsCtrl),
handlers.NewSystemsHandler(),
handlers.NewVersionHandler(),
)

service := api.New(cfg, h)
h := adapter.NewHandlers()
service := services.NewWebSrv(cfg, h)

srv.Listen(service, true)
if err := srv.Wait(); err != nil {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ volumes:
east1:
west1:
central1:
db:


networks:
Expand Down
20 changes: 0 additions & 20 deletions internal/adapter/handlers.go

This file was deleted.

25 changes: 0 additions & 25 deletions internal/adapter/handlers/systems.go

This file was deleted.

48 changes: 0 additions & 48 deletions internal/adapter/handlers/teams.go

This file was deleted.

20 changes: 0 additions & 20 deletions internal/adapter/handlers/version.go

This file was deleted.

6 changes: 3 additions & 3 deletions internal/adapter/db.go → internal/api/adapter/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package adapter
import (
"context"

openapi "github.com/zeiss/typhoon/api"
"github.com/zeiss/typhoon/internal/models"
"github.com/zeiss/typhoon/internal/ports"
"github.com/zeiss/typhoon/internal/api/models"
"github.com/zeiss/typhoon/internal/api/ports"
openapi "github.com/zeiss/typhoon/pkg/apis"

openapi_types "github.com/oapi-codegen/runtime/types"
"gorm.io/gorm"
Expand Down
17 changes: 17 additions & 0 deletions internal/api/adapter/handlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package adapter

import (
openapi "github.com/zeiss/typhoon/pkg/apis"
)

var _ openapi.StrictServerInterface = (*Handlers)(nil)

// Handlers ...
type Handlers struct {
openapi.Unimplemented
}

// NewHandlers ...
func NewHandlers() *Handlers {
return &Handlers{}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"github.com/zeiss/typhoon/internal/models"
"github.com/zeiss/typhoon/internal/api/models"
"gorm.io/gorm"
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package controllers
import (
"context"

openapi "github.com/zeiss/typhoon/api"
"github.com/zeiss/typhoon/internal/models"
"github.com/zeiss/typhoon/internal/ports"
"github.com/zeiss/typhoon/internal/api/models"
"github.com/zeiss/typhoon/internal/api/ports"
openapi "github.com/zeiss/typhoon/pkg/apis"

openapi_types "github.com/oapi-codegen/runtime/types"
)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/models/teams.go → internal/api/models/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/google/uuid"
openapi "github.com/zeiss/typhoon/api"
openapi "github.com/zeiss/typhoon/pkg/apis"
"gorm.io/gorm"
)

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions internal/ports/teams.go → internal/api/ports/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"

openapi_types "github.com/oapi-codegen/runtime/types"
openapi "github.com/zeiss/typhoon/api"
"github.com/zeiss/typhoon/internal/models"
"github.com/zeiss/typhoon/internal/api/models"
openapi "github.com/zeiss/typhoon/pkg/apis"
)

// Teams ...
Expand Down
Loading

0 comments on commit c924ba5

Please sign in to comment.