Type |聽Version
---|---
Improvement | 2.14.2
Option to manually import controller class instead of a directory search.
this.mount('/home', HomeController);
I prefer to manually import models, services and controllers without doing a directory search. Models and services can already be imported this way, but I haven't found a way for controllers. Is this possible?
Hi @Ionaru ,
You can do that with the mount options:
@ServerSettings({
"mount": {
"/rest/": [
"./controller/MyController1.js",
"./controller/MyController2.js"
]
}
})
See you :)
Romain
I'd like to do that without needing the file name, instead something like this:
import { HomeController } from './controllers/home.controller';
@ServerSettings({
// ...
})
export class Server extends ServerLoader {
// ...
public $onMountingMiddlewares(): void {
// ...
this.mount('/home', HomeController);
// ...
}
}
or through the settings
import { HomeController } from './controllers/home.controller';
import { NESController } from './controllers/nes.controller';
@ServerSettings({
// ...
"mount": {
"/rest/": [
HomeController,
NESController
]
}
})
export class Server extends ServerLoader {
// ...
}
This would be very useful for me because I am using ts-node for development & debugging and in production I want to use the compiled javascript, this means I need some way of having dynamic file extensions in the code controller.ts vs controller.js, or use the direct imports.
@Ionaru
Ok, I'll add your needs to the backlog :)
@lwallent Can I merge this feature ?
See you
Cool! I was searching for exactly this feature. Just-in-time delivery indeed! 馃嵃
Most helpful comment
@lwallent Can I merge this feature ?
See you