@@ -7,22 +7,24 @@ import type {
77 StoryBookerUser ,
88 UIAdapter ,
99} from "./adapters" ;
10+ import type { ErrorParser } from "./utils/error" ;
1011
1112export type { StoryBookerUser } from "./adapters/auth" ;
1213export type * from "./models/builds-schema" ;
1314export type * from "./models/projects-schema" ;
1415export type * from "./models/tags-schema" ;
16+ export type { ErrorParser , ParsedError } from "./utils/error" ;
1517
1618/**
17- * Options for creating a request handler .
19+ * Options for creating a router .
1820 */
1921export interface RouterOptions < User extends StoryBookerUser > {
2022 /** Adapter for Auth service. Provides authentication to the service. */
2123 auth ?: AuthAdapter < User > ;
2224 /** Adapter for Database service. Provides access to storing data to the service. */
2325 database : DatabaseAdapter ;
2426 /** Additional options to configure the router. */
25- config ?: RequestHandlerConfigOptions ;
27+ config ?: RouterConfig ;
2628 /** Adapter for Logging service. Provides option to direct the logging of the service. */
2729 logger ?: LoggerAdapter ;
2830 /** Adapter for Storage service. Provides access to storing files to the service. */
@@ -49,7 +51,7 @@ export interface PurgeHandlerOptions {
4951}
5052
5153/** Additional options to configure the router. */
52- export interface RequestHandlerConfigOptions {
54+ export interface RouterConfig {
5355 /**
5456 * A function for parsing custom errors.
5557 * Return `undefined` from parser if the service should handle the error.
@@ -75,28 +77,3 @@ export interface RequestHandlerConfigOptions {
7577 */
7678 middlewares ?: MiddlewareHandler [ ] ;
7779}
78-
79- /** Function generated to handle the incoming requests. */
80- export type RequestHandler = (
81- request : Request ,
82- overrideOptions ?: RequestHandlerOverrideOptions ,
83- ) => Promise < Response > ;
84-
85- /** Options to override properties of the request handler. */
86- export interface RequestHandlerOverrideOptions {
87- /** A abort signal that can be used to cancel the request handling. */
88- abortSignal ?: AbortSignal ;
89- /** Adapter for Logging service. Provides option to direct the logging of the service. */
90- logger ?: LoggerAdapter ;
91- }
92-
93- /**
94- * A function type for parsing custom errors.
95- * Return `undefined` from parser if the service should handle the error.
96- */
97- export type ErrorParser = ( error : unknown ) => ParsedError | undefined ;
98- export interface ParsedError {
99- errorMessage : string ;
100- errorStatus ?: number ;
101- errorType : string ;
102- }
0 commit comments