Skip to content

Commit

Permalink
fix(handleRequest): use RequestHandler as handlers type
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Sep 26, 2024
1 parent 37831ac commit c384c13
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/browser/setupWorker/start/createRequestListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
} from './utils/createMessageChannel'
import { parseWorkerRequest } from '../../utils/parseWorkerRequest'
import { RequestHandler } from '~/core/handlers/RequestHandler'
import { HttpHandler } from '~/core/handlers/HttpHandler'
import { GraphQLHandler } from '~/core/handlers/GraphQLHandler'
import { handleRequest } from '~/core/utils/handleRequest'
import { RequiredDeep } from '~/core/typeUtils'
import { devUtils } from '~/core/utils/internal/devUtils'
Expand Down Expand Up @@ -43,7 +45,11 @@ export const createRequestListener = (
await handleRequest(
request,
requestId,
context.getRequestHandlers(),
context.getRequestHandlers().filter((handler) => {
return (
handler instanceof HttpHandler || handler instanceof GraphQLHandler
)
}),
options,
context.emitter,
{
Expand Down
3 changes: 2 additions & 1 deletion src/core/utils/handleRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { until } from '@open-draft/until'
import { Emitter } from 'strict-event-emitter'
import { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'
import { RequiredDeep } from '../typeUtils'
import type { RequestHandler } from '../handlers/RequestHandler'
import { HandlersExecutionResult, executeHandlers } from './executeHandlers'
import { onUnhandledRequest } from './request/onUnhandledRequest'
import { storeResponseCookies } from './request/storeResponseCookies'
Expand Down Expand Up @@ -44,7 +45,7 @@ export interface HandleRequestOptions {
export async function handleRequest(
request: Request,
requestId: string,
handlers: Array<unknown>,
handlers: Array<RequestHandler>,
options: RequiredDeep<SharedOptions>,
emitter: Emitter<LifeCycleEventsMap>,
handleRequestOptions?: HandleRequestOptions,
Expand Down
9 changes: 8 additions & 1 deletion src/node/SetupServerCommonApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type { LifeCycleEventsMap, SharedOptions } from '~/core/sharedOptions'
import { SetupApi } from '~/core/SetupApi'
import { handleRequest } from '~/core/utils/handleRequest'
import type { RequestHandler } from '~/core/handlers/RequestHandler'
import { HttpHandler } from '~/core/handlers/HttpHandler'
import { GraphQLHandler } from '~/core/handlers/GraphQLHandler'
import type { WebSocketHandler } from '~/core/handlers/WebSocketHandler'
import { mergeRight } from '~/core/utils/internal/mergeRight'
import { InternalError, devUtils } from '~/core/utils/internal/devUtils'
Expand Down Expand Up @@ -61,7 +63,12 @@ export class SetupServerCommonApi
const response = await handleRequest(
request,
requestId,
this.handlersController.currentHandlers(),
this.handlersController.currentHandlers().filter((handler) => {
return (
handler instanceof HttpHandler ||
handler instanceof GraphQLHandler
)
}),
this.resolvedOptions,
this.emitter,
)
Expand Down

0 comments on commit c384c13

Please sign in to comment.