TypeScript HTTP handlers#4931
Conversation
This commit adds host support for registering HTTP handlers in V8 modules, and a minimal draft of TypeScript bindings support for the same. The TypeScript bindings support is fully vibe-coded and unreviewed, and is present only to allow a new smoketest, which is added to the `http_routes` suite. The host changes were also AI-assisted, but I reviewed and polished them.
coolreader18
left a comment
There was a problem hiding this comment.
Some comments, but overall LGTM
| type RouterWithRoutes = Router & { | ||
| [routesSymbol]: Route[]; | ||
| }; |
There was a problem hiding this comment.
Isn't this redundant?
| const routesSymbol = Symbol('SpacetimeDB.http.routes'); | ||
| const httpHandlerSymbol = Symbol('SpacetimeDB.http.handler'); |
There was a problem hiding this comment.
What purpose do these serve? httpHandlerSymbol seems unused and routesSymbol could just be a private field on Router with a static method to access it.
| }; | ||
| } | ||
|
|
||
| export function makeHttpNamespace(ctx: SchemaInner) { |
There was a problem hiding this comment.
It would be nice for the return value of this function (and thus also the Schema.http field) to be explicitly typed with an interface, rather than just inferred from the body.
Centril
left a comment
There was a problem hiding this comment.
Looks good; I have no comments beyond Noa's.
|
@coolreader18 @Centril to quote the PR description:
|
Based on #4636 .
Description of Changes
This commit adds host support for registering HTTP handlers in V8 modules, and a minimal draft of TypeScript bindings support for the same. The TypeScript bindings support is fully vibe-coded and unreviewed, and is present only to allow a new smoketest, which is added to the
http_routessuite. The host changes were also AI-assisted, but I reviewed and polished them.API and ABI breaking changes
Adds new TypeScript "ABI." Also adds a new API, which I sure hope will be overwritten by @JasonAtClockwork .
Expected complexity level and risk
2: pretty simple extensions to TypeScript execution, which largely mirror existing
call_proceduremachinery.Testing