Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[foal generate controller] Support sub-directories and extend the --register option #368

Closed
LoicPoullain opened this issue Feb 27, 2019 · 1 comment

Comments

@LoicPoullain
Copy link
Member

Issue

Large applications can have dozens of controllers. Placing them all at the root of the controllers/ directory is not possible in this case and we need to create subdirectories.

Unfortunately the current version of generate controller only generates controllers at the root of controllers/. In addition, the --register option only allows the controllers to be registered in app.controller.ts.

Possible solution

Let the command accept sub-directories (and create them if they do not exist already) and make the --register flag accept an optional parameter specifying the parent where to register the controller.

Example

File Structure (before)

controllers/
|- api/
|  |- user.controller.ts
|- api.controller.ts
'- auth.controller.ts
app.controller.ts

api.controller.ts (before)

...
export class ApiController {
  subDirectories = [
    controller('/users', UserController),
  ];
}

Command

foal generate controller api/products/cars --register api

File Structure (after)

controllers/
|- api/
|  |- products/
|  |  '- cars.controller.ts
|  |- user.controller.ts
|- api.controller.ts
'- auth.controller.ts
app.controller.ts

api.controller.ts (after)

...
export class ApiController {
  subDirectories = [
    controller('/users', UserController),
    controller('/products/cars', CarsController),
  ];
}
@LoicPoullain LoicPoullain added this to Backlog in Issue tracking via automation Feb 27, 2019
@LoicPoullain LoicPoullain moved this from Backlog to May 2019 in Issue tracking Mar 19, 2019
@LoicPoullain LoicPoullain moved this from To Do to Work In Progress in Issue tracking May 16, 2020
@LoicPoullain
Copy link
Member Author

Fixed in v1.9

Issue tracking automation moved this from Work In Progress to Done / Closed This Release May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Issue tracking
  
Done / Closed This Release
Development

No branches or pull requests

1 participant