Skip to content

Commit

Permalink
kruto
Browse files Browse the repository at this point in the history
  • Loading branch information
Satont committed Dec 24, 2024
1 parent 03bf4ef commit ee88249
Show file tree
Hide file tree
Showing 11 changed files with 437 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/api-gql/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_users"
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_with_roles_users"
"github.com/twirapp/twir/apps/api-gql/internal/services/timers"
ttsvoices "github.com/twirapp/twir/apps/api-gql/internal/services/tts_voices"
"github.com/twirapp/twir/apps/api-gql/internal/services/twir-users"
"github.com/twirapp/twir/apps/api-gql/internal/services/twitch"
"github.com/twirapp/twir/apps/api-gql/internal/services/users"
Expand Down Expand Up @@ -130,6 +131,7 @@ func main() {
roles_with_roles_users.New,
twitch.New,
channels.New,
ttsvoices.New,
),
// repositories
fx.Provide(
Expand Down
2 changes: 2 additions & 0 deletions apps/api-gql/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ models:
UUID:
model:
- github.com/99designs/gqlgen/graphql.UUID
Bytes:
model: "github.com/twirapp/twir/apps/api-gql/internal/delivery/gql/types.Bytes"
16 changes: 16 additions & 0 deletions apps/api-gql/internal/delivery/gql/mappers/tts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package mappers

import (
"github.com/twirapp/twir/apps/api-gql/internal/delivery/gql/gqlmodel"
"github.com/twirapp/twir/apps/api-gql/internal/entity"
)

func RHVoiceTo(e entity.TTSRHVoice) gqlmodel.RHVoice {
return gqlmodel.RHVoice{
Country: e.Country,
Gender: e.Gender,
Lang: e.Lang,
Name: e.Name,
Code: e.Code,
}
}
204 changes: 204 additions & 0 deletions apps/api-gql/internal/delivery/gql/resolvers/overlays-tts.resolver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/api-gql/internal/delivery/gql/resolvers/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_users"
"github.com/twirapp/twir/apps/api-gql/internal/services/roles_with_roles_users"
"github.com/twirapp/twir/apps/api-gql/internal/services/timers"
ttsvoices "github.com/twirapp/twir/apps/api-gql/internal/services/tts_voices"
twir_users "github.com/twirapp/twir/apps/api-gql/internal/services/twir-users"
twitchservice "github.com/twirapp/twir/apps/api-gql/internal/services/twitch"
"github.com/twirapp/twir/apps/api-gql/internal/services/users"
Expand Down Expand Up @@ -78,6 +79,7 @@ type Deps struct {
RolesUsersService *roles_users.Service
RolesWithUsersService *roles_with_roles_users.Service
TwitchService *twitchservice.Service
TTSVoicesService *ttsvoices.Service
}

type Resolver struct {
Expand Down
29 changes: 29 additions & 0 deletions apps/api-gql/internal/delivery/gql/types/bytes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package types

import (
"fmt"
"io"

"github.com/99designs/gqlgen/graphql"
)

func MarshalBytes(b []byte) graphql.Marshaler {
return graphql.WriterFunc(
func(w io.Writer) {
_, _ = fmt.Fprintf(w, "%q", string(b))
},
)
}

func UnmarshalBytes(v interface{}) ([]byte, error) {
switch v := v.(type) {
case string:
return []byte(v), nil
case *string:
return []byte(*v), nil
case []byte:
return v, nil
default:
return nil, fmt.Errorf("%T is not []byte", v)
}
}
10 changes: 10 additions & 0 deletions apps/api-gql/internal/entity/tts_voices.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package entity

type TTSRHVoice struct {
Code string
Country string
Gender string
Lang string
Name string
No int
}
18 changes: 18 additions & 0 deletions apps/api-gql/internal/server/headers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package server

import (
"context"

"github.com/twirapp/twir/apps/api-gql/internal/server/gincontext"
)

func SetHeader(ctx context.Context, key, value string) error {
gin, err := gincontext.GetGinContext(ctx)
if err != nil {
return err
}

gin.Header(key, value)

return nil
}
Loading

0 comments on commit ee88249

Please sign in to comment.