Initial cobalt setup and form/listing implementation

This commit is contained in:
2022-07-04 03:04:11 -05:00
parent 63ae51673a
commit 4715bf2758
1866 changed files with 192190 additions and 15 deletions

View File

@@ -0,0 +1,23 @@
import {Config, Inject, Injectable, Routing} from '@extollo/lib'
@Injectable()
export class Cobalt {
@Inject()
protected readonly config!: Config
@Inject()
protected readonly routing!: Routing
public getSession(): {[key: string]: any} {
return {
app: {
name: this.config.get('app.name'),
url: this.routing.getAppUrl().toRemote,
}
}
}
public getState(): {[key: string]: any} {
return {}
}
}

View File

@@ -0,0 +1,28 @@
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()
})
}
}