27 lines
813 B
TypeScript
27 lines
813 B
TypeScript
import config from "config";
|
|
import {Router} from "express";
|
|
|
|
import ApplicationComponent from "../../ApplicationComponent.js";
|
|
import MailComponent from "../MailComponent.js";
|
|
|
|
export default class AppLocalsCoreComponents extends ApplicationComponent {
|
|
private appLocals: Record<string, unknown> | undefined;
|
|
|
|
|
|
public async init(): Promise<void> {
|
|
this.appLocals = {
|
|
...config.get('app'),
|
|
version: this.getApp().getVersion(),
|
|
core_version: this.getApp().getCoreVersion(),
|
|
};
|
|
this.getApp().as(MailComponent).setAdditionalLocal('app', this.appLocals);
|
|
}
|
|
|
|
public async initRoutes(router: Router): Promise<void> {
|
|
router.use((req, res, next) => {
|
|
res.locals.app = this.appLocals;
|
|
next();
|
|
});
|
|
}
|
|
}
|