client_code_generation

package
v1.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package client_code_generation writes the TypeScript a browser calls a mux's endpoints with: one function per endpoint, taking and returning the types the endpoint declares, so that a change to what an endpoint accepts is a compile error in the code calling it rather than a failure at the request.

The runtime the generated code imports

What is generated is not standalone. It imports the functions that perform the request, encode a body and raise an error from a status from "@altshiftab/utils":

import {fetchEx, fetchWithRequest} from "@altshiftab/utils/http/utils";
import {BadStatusCodeError} from "@altshiftab/utils/http/errors";
import {encode as cborEncode} from "@altshiftab/utils/cbor";

That package belongs to one organisation, and this one does not. Generated code that only compiles for whoever can install "@altshiftab/utils" is a poor thing for a general-purpose library to produce: a caller elsewhere gets TypeScript that does not build, and nothing in the options says why. The Go here needs nothing of it -- the coupling is in script.ts.tmpl alone.

What it would take to be rid of: the module the runtime is imported from becomes an option, with the imports written against whatever it names. The names imported (fetchEx, BadStatusCodeError and the rest) would have to be part of that contract, or be named individually.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(
	endpoints []*endpointPkg.Endpoint,
	baseUrl *url.URL,
	options ...template_options.Option,
) (string, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL