seanpmaxwell / overnight

TypeScript decorators for the ExpressJS Server.
MIT License
878 stars 40 forks source link

feat(core): allow controller decorator with multi endpoints #98

Open victorhnogueira opened 2 years ago

victorhnogueira commented 2 years ago

Allow to create a controller decorator with multi endpoints just like NestJS does

Current behavior

// endpoints: /users/:id
@Controller("users")
export class UserController {
    @Get(":id")
    public async getOneUser() {
        // Logic here
    }
}

New behavior

// if you need just one endpoint:
// endpoints: /users/:id
@Controller("users")
export class UserController {
    @Get(":id")
    public async getOneUser() {
        // Logic here
    }
}

// if you need multiple endpoints:
// endpoints: /users/:id AND /potato/:id
@Controller(["users", "potato"])
export class UserController {
    @Get(":id")
    public async getOneUser() {
        // Logic here
    }
}

Related Issues:

97