refactor: wip to nestjs

This commit is contained in:
Ahmed Bouhuolia
2024-12-25 00:43:55 +02:00
parent 336171081e
commit a6932d76f3
249 changed files with 21314 additions and 1616 deletions

View File

@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { TemplateInjectable } from './TemplateInjectable.service';
@Module({
providers: [TemplateInjectable],
})
export class TemplateInjectableModule {}

View File

@@ -0,0 +1,29 @@
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,
organizationEmail: organization.metadata.email,
__: this.i18n.t,
...options,
});
}
}