Skip to content

Commit

Permalink
router matchup fixed?
Browse files Browse the repository at this point in the history
  • Loading branch information
kwhitley committed Mar 29, 2024
1 parent 2736c51 commit 544e370
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 4 additions & 0 deletions example/router-matchup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ autorouter.get('/throw', (a) => a.b.c)
router.get('/throw', (a) => a.b.c)
ittyrouter.get('/throw', (a) => a.b.c)

// autorouter tests
autorouter.missing
autorouter.format

// test response formatting
const autorouterResponse = (await autorouter.fetch(request)).foo
const routerResponse = (await router.fetch(request)).foo
Expand Down
5 changes: 2 additions & 3 deletions src/AutoRouter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Router } from './Router'
import { error } from './error'
import { json } from './json'
import { AutoRouterOptions, AutoRouterType, RouterType } from './types'
import { AutoRouterOptions, AutoRouterType, IRequest } from './types'
import { withParams } from './withParams'
import { IRequest } from './types'

export const AutoRouter = <
RequestType extends IRequest = IRequest,
Expand All @@ -15,7 +14,7 @@ export const AutoRouter = <
finally: f = [],
before = [],
...options }: AutoRouterOptions = {}
): RouterType<RequestType, Args, ResponseType> => Router({
): AutoRouterType<RequestType, Args, ResponseType> => Router({
before: [
withParams,
...before
Expand Down
13 changes: 5 additions & 8 deletions src/types/AutoRouterType.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { ErrorHandler } from './ErrorHandler'
import { IRequest } from './IRequest'
import { RequestHandler } from './RequestHandler'
import { ResponseHandler } from './ResponseHandler'
import { RouterType } from './RouterType'

// export type AutoRouterType<
// R = IRequest,
// Args extends any[] = any[],
// ResponseType = any
// > = (options?: AutoRouterOptions) => RouterType<R, Args, ResponseType>

export type AutoRouterType<R = IRequest, Args extends any[] = any[], ResponseType = any> = {
export type AutoRouterType<
R = IRequest,
Args extends any[] = any[],
ResponseType = any
> = {
missing?: RequestHandler
format?: ResponseHandler
} & RouterType<R, Args, ResponseType>

0 comments on commit 544e370

Please sign in to comment.