From 4d888bfa562bf2ce0d38dbef1f802d2f3e73a080 Mon Sep 17 00:00:00 2001 From: Ehsan Noureddin Moosa Date: Thu, 13 Jun 2024 08:15:16 +0300 Subject: [PATCH] fix github action --- .github/workflows/go.yml | 12 +- .../stub/sampleservicets/stub.ts | 199 +++++++++--------- 2 files changed, 103 insertions(+), 108 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8c279d0b..ffdd55f1 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,19 +14,11 @@ jobs: name: Set up Go ${{ matrix.go }} steps: - uses: actions/checkout@v4 - - name: Test - uses: actions/setup-go@v4 + - uses: actions/setup-go@v4 with: go-version: ${{ matrix.go }} + - name: Run Tests run: | - go work init - go work use ./kit - go work use ./std/gateways/fasthttp - go work use ./std/gateways/fastws - go work use ./std/gateways/silverhttp - go work use ./std/clusters/rediscluster - go work use ./contrib - go work sync go test -v -race -cover -covermode=atomic -coverprofile=coverage.out -count=1 \ ./kit/... \ ./std/gateways/fasthttp/... \ diff --git a/example/ex-04-stubgen/stub/sampleservicets/stub.ts b/example/ex-04-stubgen/stub/sampleservicets/stub.ts index 544e5cfe..2658b29e 100755 --- a/example/ex-04-stubgen/stub/sampleservicets/stub.ts +++ b/example/ex-04-stubgen/stub/sampleservicets/stub.ts @@ -1,157 +1,160 @@ +// Code generated by RonyKIT Stub Generator (TypeScript); DO NOT EDIT. +// @ts-ignore +import useSWR, {SWRConfiguration} from 'swr' +// ErrorMessage is a data transfer object +export interface ErrorMessage { + code: number + item: string +} -// Code generated by RonyKIT Stub Generator (TypeScript); DO NOT EDIT. - -import useSWR, { SWRConfiguration } from 'swr' - +// KeyValue is a data transfer object +export interface KeyValue { + key: string + value: number +} - // ErrorMessage is a data transfer object - export interface ErrorMessage { - code: number - item: string - } - // KeyValue is a data transfer object - export interface KeyValue { - key: string - value: number - } - // SimpleHdr is a data transfer object - export interface SimpleHdr { - sKey1: string - sKey2: number - } - // VeryComplexRequest is a data transfer object - export interface VeryComplexRequest extends SimpleHdr { - key1: string - key1Ptr?: string - mapKey1: {[key: string]: number} - mapKey2: {[key: number]: KeyValue} - sliceKey1: boolean[] - sliceKey2: KeyValue[] - rawKey: any - } - // VeryComplexResponse is a data transfer object - export interface VeryComplexResponse { - key1: string - key1Ptr?: string - mapKey1: {[key: string]: number} - mapKey2: {[key: number]: KeyValue} - sliceKey1: number[] - sliceKey2: KeyValue[] - } +// SimpleHdr is a data transfer object +export interface SimpleHdr { + sKey1: string + sKey2: number +} +// VeryComplexRequest is a data transfer object +export interface VeryComplexRequest extends SimpleHdr { + key1: string + key1Ptr?: string + mapKey1: { [key: string]: number } + mapKey2: { [key: number]: KeyValue } + sliceKey1: boolean[] + sliceKey2: KeyValue[] + rawKey: any +} +// VeryComplexResponse is a data transfer object +export interface VeryComplexResponse { + key1: string + key1Ptr?: string + mapKey1: { [key: string]: number } + mapKey2: { [key: number]: KeyValue } + sliceKey1: number[] + sliceKey2: KeyValue[] +} export class sampleServiceStub { -readonly serverURL: string ; + readonly serverURL: string; -constructor(serverURL: string) { -this.serverURL = serverURL.replace(/\/$/, ''); -} + constructor(serverURL: string) { + this.serverURL = serverURL.replace(/\/$/, ''); + } - // @ts-ignore - async complexDummy(req: VeryComplexRequest, headers?: HeadersInit): Promise { - return fetch(this.serverURL + `/complexDummy`, { + // @ts-ignore + async complexDummy(req: VeryComplexRequest, headers?: HeadersInit): Promise { + return fetch(this.serverURL + `/complexDummy`, { method: "POST", headers: { - "Content-Type": "application/json", - ...headers, + "Content-Type": "application/json", + ...headers, }, body: JSON.stringify(req) - }).then((res: Response) => { + }).then((res: Response) => { if (res.status !== 200) { - throw new Error("Failed to fetch the data"); + throw new Error("Failed to fetch the data"); } return res.json() - }) - } - // @ts-ignore - async complexDummy2(req: VeryComplexRequest, headers?: HeadersInit): Promise { - return fetch(this.serverURL + `/complexDummy/${req.key1}`, { + }) + } + + // @ts-ignore + async complexDummy2(req: VeryComplexRequest, headers?: HeadersInit): Promise { + return fetch(this.serverURL + `/complexDummy/${req.key1}`, { method: "POST", headers: { - "Content-Type": "application/json", - ...headers, + "Content-Type": "application/json", + ...headers, }, body: JSON.stringify(req) - }).then((res: Response) => { + }).then((res: Response) => { if (res.status !== 200) { - throw new Error("Failed to fetch the data"); + throw new Error("Failed to fetch the data"); } return res.json() - }) - } - // @ts-ignore - async getComplexDummy(req: VeryComplexRequest, headers?: HeadersInit): Promise { - const keys = Object.keys(req); - const keyValuePairs = keys.map(key => { + }) + } + + // @ts-ignore + async getComplexDummy(req: VeryComplexRequest, headers?: HeadersInit): Promise { + const keys = Object.keys(req); + const keyValuePairs = keys.map(key => { return encodeURIComponent(key) + '=' + encodeURIComponent((req as any)[key]); - }).join('&'); - const queryParams = (keyValuePairs.length > 0) ? `?${keyValuePairs}`: "" - const url = `${this.serverURL}/complexDummy/${req.key1}/xs/${req.sKey1}${queryParams}`; - return fetch(url, { + }).join('&'); + const queryParams = (keyValuePairs.length > 0) ? `?${keyValuePairs}` : "" + const url = `${this.serverURL}/complexDummy/${req.key1}/xs/${req.sKey1}${queryParams}`; + return fetch(url, { method: "GET", headers: { - "Content-Type": "application/json", - ...headers, + "Content-Type": "application/json", + ...headers, } - }).then((res: Response) => { + }).then((res: Response) => { if (res.status !== 200) { - throw new Error("Failed to fetch the data"); + throw new Error("Failed to fetch the data"); } return res.json() - }) - } + }) + } } // end of sampleServiceStub - export function useComplexDummy( +export function useComplexDummy( stub: sampleServiceStub, req: VeryComplexRequest, reqHeader?: HeadersInit, options?: Partial> - ) { +) { return useSWR( - [req, 'ComplexDummy'], - (req) => { - return stub.complexDummy(req[0], reqHeader) - }, - options + [req, 'ComplexDummy'], + (req) => { + return stub.complexDummy(req[0], reqHeader) + }, + options ) - } - export function useComplexDummy2( +} + +export function useComplexDummy2( stub: sampleServiceStub, req: VeryComplexRequest, reqHeader?: HeadersInit, options?: Partial> - ) { +) { return useSWR( - [req, 'ComplexDummy2'], - (req) => { - return stub.complexDummy2(req[0], reqHeader) - }, - options + [req, 'ComplexDummy2'], + (req) => { + return stub.complexDummy2(req[0], reqHeader) + }, + options ) - } - export function useGetComplexDummy( +} + +export function useGetComplexDummy( stub: sampleServiceStub, req: VeryComplexRequest, reqHeader?: HeadersInit, options?: Partial> - ) { +) { return useSWR( - [req, 'GetComplexDummy'], - (req) => { - return stub.getComplexDummy(req[0], reqHeader) - }, - options + [req, 'GetComplexDummy'], + (req) => { + return stub.getComplexDummy(req[0], reqHeader) + }, + options ) - } +}