Skip to content

Commit

Permalink
feat: add support to import RouteHandler from other modules
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasthiebaud committed Aug 30, 2020
1 parent 850a328 commit e68312b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion bin/fastify-schema-to-typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,18 @@ program
"file extension to use for generated files",
parseExtension,
".ts"
)
.option(
"-m, --module <value>",
"module to import the RouteHandler type from",
"fastify"
);

program.parse(process.argv);

convert({ glob: program.glob, prefix: program.prefix, ext: program.ext });
convert({
glob: program.glob,
prefix: program.prefix,
ext: program.ext,
module: program.module,
});
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Options {
glob: string;
prefix: string;
ext: string;
module: string;
}

export async function generateReplyInterfaces(
Expand Down Expand Up @@ -49,7 +50,7 @@ async function generateInterfaces(
* Instead, modify the corresponding JSONSchema file and regenerate the types.
*/
import { RouteHandler } from "fastify"
import { RouteHandler } from "${options.module}"
import schema from './${parsedPath.base}'
Expand Down

0 comments on commit e68312b

Please sign in to comment.