import { camel } from 'change-case';
// Provides a base class for controllers. Includes auto-naming functionality.
abstract class Controller {
// Name of the controller's application.
public static app: string;
public static name: string;
// Internal name of the controller.
private static _controller: string = null;
// Sets the private controller variable.
public static set controller(name: string) {
this._controller = name;
}
// Returns the name of the controller if set, otherwise a modified constructor name.
public static get controller(): string {
return this._controller || camel(this.name.replace(/(Ctrl|Controller)/i, ''));
}
// Instance variables set by the dispatch middleware.
public name: string;
public action: string;
public app: string;
}
export { Controller as default };
|