Skip to content

Commit

Permalink
feat: add Controller in container
Browse files Browse the repository at this point in the history
  • Loading branch information
aaydin-tr committed Apr 6, 2024
1 parent d18d21c commit bc32a5f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/decorators/controller.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Route, Constructor } from "../types";
import { Route, Constructor, ControllerOptions } from "../types";
import { Service } from "./service";

/**
Controller decorator is used to define a controller class.
It should be used on a class.
@param prefix - the prefix for all routes in the controller
**/
export function Controller(prefix: string) {
export function Controller(prefix: string, options?: ControllerOptions) {
prefix = prefix.replace(/\/$/, "");

return function <T>(target: Constructor<T>) {
Service(options)(target);
for (const value of Object.getOwnPropertyNames(target.prototype)) {
const path = Reflect.getMetadata("path", target.prototype, value);
const method = Reflect.getMetadata("method", target.prototype, value);
Expand Down

0 comments on commit bc32a5f

Please sign in to comment.