mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
Add terms and conditions data constants and update service
This commit is contained in:
7
libs/common/src/constants/terms-condtions.ts
Normal file
7
libs/common/src/constants/terms-condtions.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export const termsAndConditionsData = {
|
||||||
|
lastUpdated: '25/01/2025',
|
||||||
|
websiteUrl: 'https://www.Syncrow.ae',
|
||||||
|
mobileApp: 'Syncrow Mobile App',
|
||||||
|
companyName: 'Syncrow',
|
||||||
|
contactEmail: 'contact@Syncrow.ae',
|
||||||
|
};
|
@ -1,3 +1,4 @@
|
|||||||
|
import { termsAndConditionsData } from '@app/common/constants/terms-condtions';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@ -5,10 +6,8 @@ import * as path from 'path';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class TermsAndConditionsService {
|
export class TermsAndConditionsService {
|
||||||
async fetchTermsAndConditions(): Promise<string> {
|
async fetchTermsAndConditions(): Promise<string> {
|
||||||
// Use process.cwd() to get the current working directory (project root)
|
|
||||||
const projectRoot = process.cwd();
|
const projectRoot = process.cwd();
|
||||||
|
|
||||||
// Dynamically build the path to the terms-and-conditions.html file from the root
|
|
||||||
const filePath = path.join(
|
const filePath = path.join(
|
||||||
projectRoot,
|
projectRoot,
|
||||||
'libs',
|
'libs',
|
||||||
@ -23,28 +22,16 @@ export class TermsAndConditionsService {
|
|||||||
throw new Error(`File not found: ${filePath}`);
|
throw new Error(`File not found: ${filePath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the HTML content from the file
|
|
||||||
let htmlContent = fs.readFileSync(filePath, 'utf-8');
|
let htmlContent = fs.readFileSync(filePath, 'utf-8');
|
||||||
|
|
||||||
// Optionally, remove newlines or excess white spaces using a regular expression
|
|
||||||
htmlContent = htmlContent.replace(/(\r\n|\n|\r)/gm, ''); // Removes newlines
|
htmlContent = htmlContent.replace(/(\r\n|\n|\r)/gm, ''); // Removes newlines
|
||||||
|
|
||||||
// Define dynamic values
|
|
||||||
const dynamicValues = {
|
|
||||||
lastUpdated: '25/01/2025',
|
|
||||||
websiteUrl: 'http://www.mywebsite.com',
|
|
||||||
mobileApp: 'My Mobile App',
|
|
||||||
companyName: 'My Company',
|
|
||||||
contactEmail: 'contact@mycompany.com',
|
|
||||||
};
|
|
||||||
|
|
||||||
// Replace placeholders in the HTML with dynamic values
|
|
||||||
htmlContent = htmlContent
|
htmlContent = htmlContent
|
||||||
.replace(/{{lastUpdated}}/g, dynamicValues.lastUpdated)
|
.replace(/{{lastUpdated}}/g, termsAndConditionsData.lastUpdated)
|
||||||
.replace(/{{websiteUrl}}/g, dynamicValues.websiteUrl)
|
.replace(/{{websiteUrl}}/g, termsAndConditionsData.websiteUrl)
|
||||||
.replace(/{{mobileApp}}/g, dynamicValues.mobileApp)
|
.replace(/{{mobileApp}}/g, termsAndConditionsData.mobileApp)
|
||||||
.replace(/{{companyName}}/g, dynamicValues.companyName)
|
.replace(/{{companyName}}/g, termsAndConditionsData.companyName)
|
||||||
.replace(/{{contactEmail}}/g, dynamicValues.contactEmail);
|
.replace(/{{contactEmail}}/g, termsAndConditionsData.contactEmail);
|
||||||
|
|
||||||
return htmlContent;
|
return htmlContent;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user