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.
29 lines
786 B
29 lines
786 B
import {Inject, Maybe, Request, Singleton, Unit, ViewEngine} from '@extollo/lib'
|
|
import {Cobalt} from './Cobalt.service'
|
|
|
|
@Singleton()
|
|
export class CobaltUnit extends Unit {
|
|
@Inject()
|
|
protected readonly viewEngine!: ViewEngine
|
|
|
|
up(): Promise<void> | void {
|
|
this.viewEngine.registerGlobalFactory('cobaltSession', (req: Maybe<Request>) => {
|
|
if ( !req ) {
|
|
return
|
|
}
|
|
|
|
const cobalt = req.make<Cobalt>(Cobalt)
|
|
return cobalt.getSession()
|
|
})
|
|
|
|
this.viewEngine.registerGlobalFactory('cobaltState', (req: Maybe<Request>) => {
|
|
if ( !req ) {
|
|
return
|
|
}
|
|
|
|
const cobalt = req.make<Cobalt>(Cobalt)
|
|
return cobalt.getState()
|
|
})
|
|
}
|
|
}
|