Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: relative hono handler imports when using tag mode #1574

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/hono/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ export const getHonoHeader: ClientHeaderBuilder = ({
clientImplementation.includes(`${verbOption.operationName}Handlers`),
)
.map((verbOption) => {
const isTagMode =
output.mode === 'tags' || output.mode === 'tags-split';
const tag = kebab(verbOption.tags[0] ?? 'default');

const handlersPath = upath.relativeSafe(
targetInfo.dirname ?? '',
upath.join(targetInfo.dirname ?? '', isTagMode ? tag : ''),
upath.join(
handlerFileInfo.dirname ?? '',
`./${verbOption.operationName}`,
Expand Down Expand Up @@ -151,7 +155,7 @@ const getHonoHandlers = ({
return `
export const ${handlerName} = factory.createHandlers(
${currentValidator}async (c: ${contextTypeName}) => {

},
);`;
};
Expand Down Expand Up @@ -861,7 +865,7 @@ export const zValidator =
}
} else {
await next();

if (
c.res.status !== 200 ||
!c.res.headers.get('Content-Type')?.includes('application/json')
Expand All @@ -877,7 +881,7 @@ export const zValidator =
} catch {
const message = 'Malformed JSON in response';
c.res = new Response(message, { status: 400 });

return;
}

Expand Down