Skip to content

Commit 692f749

Browse files
committedMay 13, 2024
fix(hono): remove handler fix
1 parent 404c197 commit 692f749

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed
 

‎packages/hono/src/index.ts

+3-32
Original file line numberDiff line numberDiff line change
@@ -178,26 +178,6 @@ const getZvalidatorImports = (verbOption: GeneratorVerbOptions) => {
178178
return imports.join(',\n');
179179
};
180180

181-
const getHandlerFix = ({
182-
rawFile,
183-
content,
184-
}: {
185-
rawFile: string;
186-
content: string;
187-
}) => {
188-
let newContent = content;
189-
190-
if (!rawFile.includes("import { createFactory } from 'hono/factory';")) {
191-
newContent = `import { createFactory } from 'hono/factory';\n${newContent}`;
192-
}
193-
194-
if (!rawFile.includes('const factory = createFactory();')) {
195-
newContent += '\nconst factory = createFactory();';
196-
}
197-
198-
return newContent;
199-
};
200-
201181
const getVerbOptionGroupByTag = (
202182
verbOptions: Record<string, GeneratorVerbOptions>,
203183
) => {
@@ -251,10 +231,7 @@ const generateHandlers = async (
251231

252232
if (isExist) {
253233
const rawFile = await fs.readFile(handlerPath, 'utf8');
254-
let content = getHandlerFix({
255-
rawFile,
256-
content: rawFile,
257-
});
234+
let content = rawFile;
258235

259236
if (!rawFile.includes(handlerName)) {
260237
content += getHonoHandlers({
@@ -317,10 +294,7 @@ ${getHonoHandlers({
317294

318295
if (isExist) {
319296
const rawFile = await fs.readFile(handlerPath, 'utf8');
320-
let content = getHandlerFix({
321-
rawFile,
322-
content: rawFile,
323-
});
297+
let content = rawFile;
324298

325299
content += Object.values(verbs).reduce((acc, verbOption) => {
326300
const handlerName = `${verbOption.operationName}Handlers`;
@@ -398,10 +372,7 @@ const factory = createFactory();`;
398372

399373
if (isExist) {
400374
const rawFile = await fs.readFile(handlerPath, 'utf8');
401-
let content = getHandlerFix({
402-
rawFile,
403-
content: rawFile,
404-
});
375+
let content = rawFile;
405376

406377
content += Object.values(verbOptions).reduce((acc, verbOption) => {
407378
const handlerName = `${verbOption.operationName}Handlers`;

0 commit comments

Comments
 (0)
Please sign in to comment.