Skip to content

Commit

Permalink
fix: explicit return types
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed May 28, 2024
1 parent a5e3c5c commit a8bd7dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ class UrlNode {
export async function createRouter(
dir: string,
{ baseUrl = '', dev = false }: { baseUrl?: string; dev?: boolean } = {},
) {
): Promise<{
handler: (req: Request) => Promise<Response>
}> {
const root = new UrlNode()

/** req.url.pathname -> { match, params } */
Expand Down Expand Up @@ -306,7 +308,9 @@ export async function createRouter(
return new Response('Not Found', { status: 404 })
}

return { handler }
return {
handler,
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Deno.test('router', async (t) => {
}

const { handler } = await createRouter(temp.path, { baseUrl: '/api' })
using server = new Server((req) => handler(req))
using server = new Server(handler)

// #endregion

Expand Down

0 comments on commit a8bd7dc

Please sign in to comment.