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