feat: error when action handler is missing
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user