Skip to content

Commit e68312b

Browse files
feat: add support to import RouteHandler from other modules
1 parent 850a328 commit e68312b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

bin/fastify-schema-to-typescript.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,18 @@ program
3838
"file extension to use for generated files",
3939
parseExtension,
4040
".ts"
41+
)
42+
.option(
43+
"-m, --module <value>",
44+
"module to import the RouteHandler type from",
45+
"fastify"
4146
);
4247

4348
program.parse(process.argv);
4449

45-
convert({ glob: program.glob, prefix: program.prefix, ext: program.ext });
50+
convert({
51+
glob: program.glob,
52+
prefix: program.prefix,
53+
ext: program.ext,
54+
module: program.module,
55+
});

src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface Options {
1111
glob: string;
1212
prefix: string;
1313
ext: string;
14+
module: string;
1415
}
1516

1617
export async function generateReplyInterfaces(
@@ -49,7 +50,7 @@ async function generateInterfaces(
4950
* Instead, modify the corresponding JSONSchema file and regenerate the types.
5051
*/
5152
52-
import { RouteHandler } from "fastify"
53+
import { RouteHandler } from "${options.module}"
5354
5455
import schema from './${parsedPath.base}'
5556

0 commit comments

Comments
 (0)