diff --git a/src/generate/cli.ts b/src/generate/cli.ts index 79455de..bb533d2 100644 --- a/src/generate/cli.ts +++ b/src/generate/cli.ts @@ -18,8 +18,10 @@ const coerceSchematicAliases = (arg: string) => { return "provider"; case "e": return "entity"; - case "m": + case "mo": return "module"; + case "m": + return "middleware"; default: return arg; } @@ -40,6 +42,7 @@ const generateProject = (): CommandModule => { "provider", "entity", "module", + "middleware", ] as const, describe: "The schematic to generate", type: "string", diff --git a/src/generate/form.ts b/src/generate/form.ts index 099f99a..8c1d17e 100644 --- a/src/generate/form.ts +++ b/src/generate/form.ts @@ -448,6 +448,8 @@ const schematicFolder = (schematic: string): string | undefined => { return "providers"; case "entity": return "entities"; + case "middleware": + return "providers/middlewares"; } return undefined; diff --git a/src/generate/templates/middleware.tpl b/src/generate/templates/middleware.tpl new file mode 100644 index 0000000..1dac6d1 --- /dev/null +++ b/src/generate/templates/middleware.tpl @@ -0,0 +1,10 @@ +import { ExpressoMiddleware } from "@expressots/core"; +import { NextFunction, Request, Response } from "express"; +import { provide } from "inversify-binding-decorators"; + +@provide({{className}}Middleware) +export class {{className}}Middleware extends ExpressoMiddleware { + use(req: Request, res: Response, next: NextFunction): void | Promise { + throw new Error("Method not implemented."); + } +} \ No newline at end of file