Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion _examples/node-ts/server/server.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
// node-ts v1.0.0 2167bb6fb0a186ff099cd8a309c6ffbbd7d1b9c0
// --
// Code generated by webrpc-gen@v0.11.0 with custom generator. DO NOT EDIT.
// Code generated by webrpc-gen@v0.13.1 with ../../ generator. DO NOT EDIT.
//
// webrpc-gen -schema=service.ridl -target=../../ -server -out=./server/server.gen.ts

Expand All @@ -24,6 +24,11 @@ export enum Kind {
ADMIN = 'ADMIN'
}

export enum KindValue {
USER = 0,
ADMIN = 1
}

export interface User {
id: number
USERNAME: string
Expand Down
22 changes: 21 additions & 1 deletion _examples/node-ts/webapp/client.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
// node-ts v1.0.0 2167bb6fb0a186ff099cd8a309c6ffbbd7d1b9c0
// --
// Code generated by webrpc-gen@v0.11.0 with custom generator. DO NOT EDIT.
// Code generated by webrpc-gen@v0.13.1 with ../../ generator. DO NOT EDIT.
//
// webrpc-gen -schema=service.ridl -target=../../ -client -out=./webapp/client.gen.ts

Expand All @@ -24,6 +24,11 @@ export enum Kind {
ADMIN = 'ADMIN'
}

export enum KindValue {
USER = 0,
ADMIN = 1
}

export interface User {
id: number
USERNAME: string
Expand Down Expand Up @@ -259,6 +264,19 @@ export class WebrpcServerPanicError extends WebrpcError {
}
}

export class WebrpcInternalErrorError extends WebrpcError {
constructor(
name: string = 'WebrpcInternalError',
code: number = -7,
message: string = 'internal error',
status: number = 0,
cause?: string
) {
super(name, code, message, status, cause)
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype)
}
}


// Schema errors

Expand All @@ -271,6 +289,7 @@ export enum errors {
WebrpcBadRequest = 'WebrpcBadRequest',
WebrpcBadResponse = 'WebrpcBadResponse',
WebrpcServerPanic = 'WebrpcServerPanic',
WebrpcInternalError = 'WebrpcInternalError',
}

const webrpcErrorByCode: { [code: number]: any } = {
Expand All @@ -281,6 +300,7 @@ const webrpcErrorByCode: { [code: number]: any } = {
[-4]: WebrpcBadRequestError,
[-5]: WebrpcBadResponseError,
[-6]: WebrpcServerPanicError,
[-7]: WebrpcInternalErrorError,
}

export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
7 changes: 7 additions & 0 deletions types.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export enum {{$type.Name}} {
{{$field.Name}} = '{{$field.Name}}'
{{- end}}
}

export enum {{$type.Name}}Value {
{{- range $i, $field := $type.Fields}}
{{- if $i}},{{end}}
{{$field.Name}} = {{$field.TypeExtra.Value}}
{{- end}}
}
{{end -}}

{{- if isStructType $type }}
Expand Down