Nunjucks: distinguish application version from core version
This commit is contained in:
parent
d676caa3dc
commit
9b7ec1e516
@ -7,8 +7,8 @@ import ApplicationComponent from "./ApplicationComponent";
|
||||
import Controller from "./Controller";
|
||||
import MysqlConnectionManager from "./db/MysqlConnectionManager";
|
||||
import Migration from "./db/Migration";
|
||||
import TemplateError = lib.TemplateError;
|
||||
import {Type} from "./Utils";
|
||||
import TemplateError = lib.TemplateError;
|
||||
|
||||
export default abstract class Application {
|
||||
private readonly version: string;
|
||||
@ -34,6 +34,7 @@ export default abstract class Application {
|
||||
this.webSocketListeners[path] = thing;
|
||||
Logger.info(`Added websocket listener on ${path}`);
|
||||
} else {
|
||||
thing.setApp(this);
|
||||
this.components.push(thing);
|
||||
}
|
||||
}
|
||||
@ -156,4 +157,8 @@ export default abstract class Application {
|
||||
public isReady(): boolean {
|
||||
return this.ready;
|
||||
}
|
||||
|
||||
public getVersion(): string {
|
||||
return this.version;
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
import {Express, Router} from "express";
|
||||
import Logger from "./Logger";
|
||||
import {sleep} from "./Utils";
|
||||
import Application from "./Application";
|
||||
|
||||
export default abstract class ApplicationComponent<T> {
|
||||
private val?: T;
|
||||
protected app?: Application;
|
||||
|
||||
public abstract async start(app: Express, router: Router): Promise<void>;
|
||||
|
||||
@ -18,6 +20,10 @@ export default abstract class ApplicationComponent<T> {
|
||||
return this.val;
|
||||
}
|
||||
|
||||
public setApp(app: Application) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
protected async prepare(name: string, prepare: () => Promise<void>): Promise<void> {
|
||||
let err;
|
||||
do {
|
||||
|
@ -18,7 +18,8 @@ export default class NunjucksComponent extends ApplicationComponent<void> {
|
||||
if (path === null) throw new ServerError(`Route ${route} not found.`);
|
||||
return path;
|
||||
})
|
||||
.addGlobal('app_version', require('../package.json').version)
|
||||
.addGlobal('app_version', this.app!.getVersion())
|
||||
.addGlobal('core_version', require('../package.json').version)
|
||||
.addFilter('hex', (v: number) => {
|
||||
return v.toString(16);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user