Skip to content

Commit

Permalink
feat: add middleware scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
juliano-soares committed Mar 18, 2024
1 parent f758f1b commit 5ffcac1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/generate/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -40,6 +42,7 @@ const generateProject = (): CommandModule<CommandModuleArgs, any> => {
"provider",
"entity",
"module",
"middleware",
] as const,
describe: "The schematic to generate",
type: "string",
Expand Down
2 changes: 2 additions & 0 deletions src/generate/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ const schematicFolder = (schematic: string): string | undefined => {
return "providers";
case "entity":
return "entities";
case "middleware":
return "providers/middlewares";
}

return undefined;
Expand Down
10 changes: 10 additions & 0 deletions src/generate/templates/middleware.tpl
Original file line number Diff line number Diff line change
@@ -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<void> {
throw new Error("Method not implemented.");
}
}

0 comments on commit 5ffcac1

Please sign in to comment.