24 lines
763 B
TypeScript
24 lines
763 B
TypeScript
import {Instantiable, FactoryProducer} from '../di'
|
|
import {ViewEngine} from './ViewEngine'
|
|
import {PugViewEngine} from './PugViewEngine'
|
|
import {ConfiguredSingletonFactory} from '../di/factory/ConfiguredSingletonFactory'
|
|
|
|
/**
|
|
* Dependency factory whose token matches the abstract ViewEngine class, but produces
|
|
* a particular ViewEngine implementation based on the configuration.
|
|
*/
|
|
@FactoryProducer()
|
|
export class ViewEngineFactory extends ConfiguredSingletonFactory<ViewEngine> {
|
|
protected getConfigKey(): string {
|
|
return 'server.view_engine.driver'
|
|
}
|
|
|
|
protected getDefaultImplementation(): Instantiable<ViewEngine> {
|
|
return PugViewEngine
|
|
}
|
|
|
|
protected getAbstractImplementation(): any {
|
|
return ViewEngine
|
|
}
|
|
}
|