typescript-rest
typescript-rest copied to clipboard
loadControllers Not import sub directory
When using controller directory have subdicrectory.
directory example
src
├── controller
│ └── host
│ └── host-first-controller.ts
│ └── host-second-controller.ts
│ └── guest
│ └── guest-first-controller.ts
│ └── guest-second-controller.ts
│ └── main-controller.ts
I try include controller /**/*.ts but only load main-controller.ts
Server.loadControllers(this.app, 'controller/**/*.ts', __dirname);
Temporary use directly load directory.
Server.loadControllers(this.app, 'controller/*.ts', __dirname);
Server.loadControllers(this.app, 'controller/host/*.ts', __dirname);
Server.loadControllers(this.app, 'controller/guest/*.ts', __dirname);
please fix load subdirectory use /**/*.ts.
Hi,
I think that your code can not work once compiled, it will work in typescript (ie: if you run your code with ts-node), but not after compilation ... as the string controller/**/*.ts will not change, so, as after compilation phase, all your files are changed to javascript (with a js extension) so it will not match anything.
Try to do something like this :
Server.loadControllers(this.app, 'controller/**/*.js', __dirname);
Or
Server.loadControllers(this.app, 'controller/**/*Controller.*', __dirname);
Just do not reference .ts files ...
Regards ...