mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TemplateInjectable } from './TemplateInjectable.service';
|
||||
import { TenancyContext } from '../Tenancy/TenancyContext.service';
|
||||
|
||||
@Module({
|
||||
providers: [TemplateInjectable, TenancyContext],
|
||||
exports: [TemplateInjectable]
|
||||
})
|
||||
export class TemplateInjectableModule {}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { I18nService } from 'nestjs-i18n';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { TenancyContext } from '../Tenancy/TenancyContext.service';
|
||||
import { templateRender } from '@/utils/template-render';
|
||||
|
||||
@Injectable()
|
||||
export class TemplateInjectable {
|
||||
constructor(
|
||||
private readonly tenancyContext: TenancyContext,
|
||||
private readonly i18n: I18nService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Renders the given filename of the template.
|
||||
* @param {string} filename
|
||||
* @param {Record<string, any>} options
|
||||
* @returns {string}
|
||||
*/
|
||||
public async render(filename: string, options: Record<string, any>) {
|
||||
const organization = await this.tenancyContext.getTenant(true);
|
||||
|
||||
return templateRender(filename, {
|
||||
organizationName: organization.metadata.name,
|
||||
// @todo email
|
||||
organizationEmail: '',
|
||||
__: this.i18n.t,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user