Expand description
§alux-http-typescript
alux-http-typescript interprets an alux-http program as the
TypeScript client that calls it.
The same program an executing interpretation answers is read here from the other side: what a caller states, where each argument goes, and what comes back. Nothing about the surface is written a second time in another language, which is what makes a client and a service unable to disagree about it.
use alux_http::HttpProgramExt;
use alux_http_typescript::TsHttpClient;
use alux_shape::Spelling;
let client = TsHttpClient::new(Spelling::LowerCamel);
let module = client.compile_http(client.status_api::<App>());
println!("{}", module.render());A generated module states each call as the program states it:
export const program = {
readingAt: endpoint<[id: number], Reading>("GET", "/readings/{id}", ["path"]),
} as const§One call per operation
Each call is named after the operation it calls. Declare the same operation on two endpoints and the module has one call, the last one declared. Give each endpoint its own operation to get two calls.
A server still answers both paths, and alux-http-text and
alux-http-openapi still describe both.
The method, the path template, and where each argument goes are read from the declaration. A
described path is already a template, so nothing is spelled a second way for a caller. endpoint
comes from the runtime package, so a surface and what makes a surface’s requests are upgraded
separately.
Interprets typed HTTP programs as the TypeScript client that calls them.
The same program an executing interpretation answers is read here from the other side: what a caller states, where each argument goes, and what comes back. Nothing about the surface is written a second time in another language.
Structs§
- TsArgument
- One argument, as a call takes it.
- TsBody
Input - Takes a request body written as a document.
- TsBytes
Output - Answers a caller with the bytes a raw-byte answer states.
- TsCall
- One call, before the method and path it is made under are composed around it.
- TsCookie
Input - Takes a cookie the caller sends.
- TsEmpty
Output - Answers a caller with what an answer with no body states.
- TsFile
Output - Answers a caller with the bytes a streamed file states.
- TsForm
Input - Takes a request body written as a form.
- TsHeader
Input - Takes a header the caller sends.
- TsHeader
Output - Answers with what the kind beneath states, since a header reaches a caller beside it.
- TsHtml
Output - Answers a caller with what HTML states.
- TsHttp
Client - Interprets typed HTTP programs as a TypeScript client module.
- TsHttp
Module - A client module: the declarations its calls depend on, and the calls themselves.
- TsJson
Output - Answers with whatever the handler’s result states.
- TsMultipart
Input - Takes a request body written as parts.
- TsPath
Input - Takes a segment the path binds.
- TsQuery
Input - Takes a value in the query string.
- TsRaw
Body Input - Takes a request body sent as it stands.
- TsRedirect
Output - Answers a caller with what a redirect states.
- TsResult
Output - Answers with what the kind beneath states, since a failure rejects the call instead.
- TsRoute
Impl - Composes route selection as the method and path a call is made under.
- TsSelector
- Carries route-selection meaning, which a call reads as a method and a path template.
- TsStatus
Output - Answers with what the kind beneath states, whatever status the endpoint declared.
- TsStream
Output - Answers a caller with the bytes a streamed answer states.
- TsText
Output - Answers a caller with what plain text states.
- TsUnstated
Input - Takes nothing, because a caller states nothing here.
Enums§
- TsSource
- Where a call says one argument goes.
Constants§
- RUNTIME_
PACKAGE - The package that interprets a program: what turns one into calls, installed once.
Traits§
- TsInput
Alg - States how a call takes one argument.
- TsInputs
Alg - States the whole argument product a call takes, in declaration order.
- TsOutput
Alg - States what one output kind answers a caller with.