Skip to content

Commit

Permalink
add response types for user/subscription endpoints (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuccaBitfly authored May 17, 2024
1 parent dd78588 commit e741127
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/pkg/api/handlers/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (h *HandlerService) InternalGetProductSummary(w http.ResponseWriter, r *htt
handleErr(w, err)
return
}
response := types.ApiDataResponse[types.ProductSummary]{
response := types.InternalGetProductSummaryResponse{
Data: *data,
}
returnOk(w, response)
Expand Down Expand Up @@ -88,7 +88,7 @@ func (h *HandlerService) InternalGetUserInfo(w http.ResponseWriter, r *http.Requ
handleErr(w, err)
return
}
response := types.ApiDataResponse[types.UserInfo]{
response := types.InternalGetUserInfoResponse{
Data: *userInfo,
}
returnOk(w, response)
Expand Down
4 changes: 4 additions & 0 deletions backend/pkg/api/types/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type UserSubscription struct {
End int64 `json:"end" faker:"unix_time"`
}

type InternalGetUserInfoResponse ApiDataResponse[UserInfo]

type ProductCategory string

const ProductCategoryApi ProductCategory = "api"
Expand All @@ -29,6 +31,8 @@ type ProductSummary struct {
ExtraDashboardValidatorsPremiumAddon []ExtraDashboardValidatorsPremiumAddon `json:"extra_dashboard_validators_premium_addons"`
}

type InternalGetProductSummaryResponse ApiDataResponse[ProductSummary]

type ApiProduct struct {
ProductId string `json:"product_id"`
ProductName string `json:"product_name"`
Expand Down
3 changes: 3 additions & 0 deletions frontend/types/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Code generated by tygo. DO NOT EDIT.
/* eslint-disable */
import type { ApiDataResponse } from './common'

//////////
// source: user.go
Expand All @@ -19,6 +20,7 @@ export interface UserSubscription {
start: number /* int64 */;
end: number /* int64 */;
}
export type InternalGetUserInfoResponse = ApiDataResponse<UserInfo>;
export type ProductCategory = string;
export const ProductCategoryApi: ProductCategory = "api";
export const ProductCategoryPremium: ProductCategory = "premium";
Expand All @@ -28,6 +30,7 @@ export interface ProductSummary {
premium_products: PremiumProduct[];
extra_dashboard_validators_premium_addons: ExtraDashboardValidatorsPremiumAddon[];
}
export type InternalGetProductSummaryResponse = ApiDataResponse<ProductSummary>;
export interface ApiProduct {
product_id: string;
product_name: string;
Expand Down

0 comments on commit e741127

Please sign in to comment.