Me and @petrck were discussing the file Results.ts, which seems to be result types for controllers.
The first thing that came up was that the name was probably not optimal, renaming it to ControllerResult or ControllerResponse would be a more describing name, as it's currently not clear what it does.
Secondly there's the issue of Application being referenced in all of the methods (and only being used twice, just for the root directory of the application). Snippet:
I suggest the best way to fix this is by passing the rootDirectory to every controller, and having the controller pass it on to the actionresult like so:
// Application.ts
let controller = new Controller(this.rootDirectory);
// Controller.ts
export class Controller
{
public constructor(private rootDirectory: string) { ... }
}
// ControllerResult.ts
export class IActionResult
{
execute(response: Response, rootDirectory: string);
}
// SomeController.ts
export class SomeController extends Controller
{
public someAction(request: Request, response: Response): IActionResult
{
return new SubClassOfActionResult(this.rootDirectory, response); // <-- this should probably be automatic, I never really used action results in the framework
}
}
Me and @petrck were discussing the file Results.ts, which seems to be result types for controllers.
The first thing that came up was that the name was probably not optimal, renaming it to
ControllerResult
orControllerResponse
would be a more describing name, as it's currently not clear what it does.Secondly there's the issue of
Application
being referenced in all of the methods (and only being used twice, just for the root directory of the application). Snippet:I suggest the best way to fix this is by passing the
rootDirectory
to every controller, and having the controller pass it on to the actionresult like so: