You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
926 B
25 lines
926 B
import { InstantiableCanonical } from './InstantiableCanonical.ts'
|
|
import { CanonicalDefinition } from './Canonical.ts'
|
|
import Controller from '../http/Controller.ts'
|
|
import { Unit } from '../lifecycle/decorators.ts'
|
|
|
|
/**
|
|
* Canonical method which loads controllers, and returns an instance of the controller.
|
|
* @extends InstantiableCanonical
|
|
*/
|
|
@Unit()
|
|
export default class Controllers extends InstantiableCanonical<Controller> {
|
|
protected base_path = './app/http/controllers'
|
|
protected canonical_item = 'controller'
|
|
protected suffix = '.controller.ts'
|
|
|
|
public async init_canonical_item(def: CanonicalDefinition) {
|
|
const item = await super.init_canonical_item(def)
|
|
if ( !(item instanceof Controller) ) {
|
|
throw new TypeError(`Invalid controller definition: ${def.original_name}. Controllers must extend from Daton's base Controller class.`)
|
|
}
|
|
|
|
return item
|
|
}
|
|
}
|