mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 22:45:09 +00:00
fix ts template
This commit is contained in:
@@ -14,14 +14,14 @@ export class Client {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const tsServiceTemplate = `import * as m3o from '@m3o/m3o-node';
|
const tsServiceTemplate = `import * as micro from 'micro-js-client';
|
||||||
|
|
||||||
{{ $service := .service }}
|
{{ $service := .service }}
|
||||||
export class {{ title $service.Name }}Service{
|
export class {{ title $service.Name }}Service{
|
||||||
private client: m3o.Client;
|
private client: micro.Client;
|
||||||
|
|
||||||
constructor(token: string) {
|
constructor(token: string) {
|
||||||
this.client = new m3o.Client({token: token})
|
this.client = new micro.Client({token: token})
|
||||||
}
|
}
|
||||||
{{ range $key, $req := $service.Spec.Components.RequestBodies }}{{ $endpointName := requestTypeToEndpointName $key}}{{ if endpointComment $endpointName $service.Spec.Components.Schemas }}{{ endpointComment $endpointName $service.Spec.Components.Schemas }}{{ end }}{{ untitle $endpointName}}(request: {{ requestType $key }}): Promise<{{ requestTypeToResponseType $key }}> {
|
{{ range $key, $req := $service.Spec.Components.RequestBodies }}{{ $endpointName := requestTypeToEndpointName $key}}{{ if endpointComment $endpointName $service.Spec.Components.Schemas }}{{ endpointComment $endpointName $service.Spec.Components.Schemas }}{{ end }}{{ untitle $endpointName}}(request: {{ requestType $key }}): Promise<{{ requestTypeToResponseType $key }}> {
|
||||||
return this.client.call("{{ $service.Name }}", "{{ requestTypeToEndpointPath $key}}", request) as Promise<{{ requestTypeToResponseType $key }}>;
|
return this.client.call("{{ $service.Name }}", "{{ requestTypeToEndpointPath $key}}", request) as Promise<{{ requestTypeToResponseType $key }}>;
|
||||||
@@ -35,7 +35,7 @@ export interface {{ title $typeName }}{{ "{" }}
|
|||||||
{{end}}
|
{{end}}
|
||||||
`
|
`
|
||||||
|
|
||||||
const tsExampleTemplate = `{{ $service := .service }}const { {{ title $service.Name }}Service } = require('m3o/{{ $service.Name }}');
|
const tsExampleTemplate = `{{ $service := .service }}const { {{ title $service.Name }}Service } = require('micro-js-client/{{ $service.Name }}');
|
||||||
|
|
||||||
{{ if endpointComment .endpoint $service.Spec.Components.Schemas }}{{ endpointComment .endpoint $service.Spec.Components.Schemas }}{{ end }}async function {{ untitle .funcName }}() {
|
{{ if endpointComment .endpoint $service.Spec.Components.Schemas }}{{ endpointComment .endpoint $service.Spec.Components.Schemas }}{{ end }}async function {{ untitle .funcName }}() {
|
||||||
let {{ $service.Name }}Service = new {{ title $service.Name }}Service(process.env.MICRO_API_TOKEN)
|
let {{ $service.Name }}Service = new {{ title $service.Name }}Service(process.env.MICRO_API_TOKEN)
|
||||||
|
|||||||
Reference in New Issue
Block a user