Skip to content

Commit

Permalink
feat(backend): add automatically generated typescript types based on …
Browse files Browse the repository at this point in the history
…go code
  • Loading branch information
Fx64b committed Dec 13, 2024
1 parent 56a080c commit b537a11
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
jq ".version = \"$VERSION\"" web/package.json > tmp.$$.json && mv tmp.$$.json web/package.json
shell: bash

# TODO: only update if there are any changes

- name: Commit updated web/package.json
run: |
git config --global user.name "GitHub Actions"
Expand Down
6 changes: 6 additions & 0 deletions services/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ RUN go mod download

COPY . .

# Generate TypeScript files from Go structs
RUN go install github.com/gzuidhof/tygo@latest && \
tygo generate && \
mkdir -p /app/web/types && \
mv generated/types/index.ts /app/web/types/index.ts

RUN go build -o main ./cmd/api

EXPOSE 8080
Expand Down
Empty file.
9 changes: 9 additions & 0 deletions services/backend/tygo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
packages:
- path: "video-archiver/models"
output_path: "./generated/types"
type_mappings:
time.Time: "string /* RFC3339 */"
null.String: "null | string"
null.Bool: "null | boolean"
uuid.UUID: "string /* uuid */"
uuid.NullUUID: "null | string /* uuid */"

0 comments on commit b537a11

Please sign in to comment.