Template
1
0

feat: error when action handler is missing

This commit is contained in:
2025-04-18 22:44:46 +00:00
parent d7398f6bff
commit ecb5f80584
6 changed files with 22 additions and 2 deletions

View File

@@ -126,7 +126,10 @@ export class Api<TRoutes extends Route[]> {
if (result.success === false) {
return toResponse(new BadRequestError("Invalid action input", z.prettifyError(result.error)));
}
const output = (await action.state.handle?.(result.data)) ?? {};
if (action.state.handle === undefined) {
return toResponse(new InternalServerError(`Action '${action.state.name}' is missing handler.`));
}
const output = await action.state.handle(result.data);
for (const key in output) {
context[key] = output[key];
}

View File

@@ -24,6 +24,13 @@ export class Relay<TRoutes extends Route[]> {
}
}
/**
* Override relay url configuration.
*/
set url(value: string) {
this.config.url = value;
}
/**
* Retrieve a route for the given method/path combination which can be further extended
* for serving incoming third party requests.