diff --git a/libs/common/src/constants/controller-route.ts b/libs/common/src/constants/controller-route.ts index f257e2a..d82aebe 100644 --- a/libs/common/src/constants/controller-route.ts +++ b/libs/common/src/constants/controller-route.ts @@ -413,6 +413,16 @@ export class ControllerRoute { 'This endpoint retrieves the terms and conditions for the application.'; }; }; + + static PRIVACY_POLICY = class { + public static readonly ROUTE = 'policy'; + + static ACTIONS = class { + public static readonly FETCH_POLICY_SUMMARY = 'Fetch Privacy Policy'; + public static readonly FETCH_POLICY_DESCRIPTION = + 'This endpoint retrieves the privacy policy for the application.'; + }; + }; static GROUP = class { public static readonly ROUTE = 'group'; diff --git a/libs/common/src/constants/privacy-policy.html b/libs/common/src/constants/privacy-policy.html new file mode 100644 index 0000000..e33fabf --- /dev/null +++ b/libs/common/src/constants/privacy-policy.html @@ -0,0 +1,37 @@ +
+

Syncrow Mobile Privacy Policy

+

+ Effective Date: 26/06/2022
+ Updated: 26/06/2022 +

+

+ Syncrow and subsidiaries (“we”, “us”, “our”, “Syncrow”) are committed to + protecting your privacy. This Privacy Policy (“Policy”) describes our + practices in connection with information privacy on Personal Data we process + through your individual use of the following services, products, and related + mobile applications (collectively, the “Products”): +

+ +

+ Before you use our Products, please carefully read through this Policy and + understand our purposes and practices of collection, processing of your + Personal Data, including how we use, store, share and transfer Personal + Data. In the Policy you will also find ways to execute your rights of + access, update, delete or protect your Personal Data. +

+

+ When you accept this Policy when you register with your Personal Data, or if + you start to use our Products and does not expressly object to the contents + of this Policy, we will consider that you fully understand and agree with + this Policy. If you have any questions regarding this Policy, please do not + hesitate to contact us via: +

+

+ For other branded mobile applications powered by Syncrow, our Clients + control all the Personal Data collected through our Products. We collect the + information under the direction of our Clients and the processing of such + information. +

+
diff --git a/src/app.module.ts b/src/app.module.ts index d61ac4c..f941837 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -27,6 +27,7 @@ import { InviteUserModule } from './invite-user/invite-user.module'; import { PermissionModule } from './permission/permission.module'; import { RoleModule } from './role/role.module'; import { TermsConditionsModule } from './terms-conditions/terms-conditions.module'; +import { PrivacyPolicyModule } from './privacy-policy/privacy-policy.module'; @Module({ imports: [ ConfigModule.forRoot({ @@ -57,6 +58,7 @@ import { TermsConditionsModule } from './terms-conditions/terms-conditions.modul PermissionModule, RoleModule, TermsConditionsModule, + PrivacyPolicyModule, ], providers: [ { diff --git a/src/privacy-policy/controllers/index.ts b/src/privacy-policy/controllers/index.ts new file mode 100644 index 0000000..1ef7536 --- /dev/null +++ b/src/privacy-policy/controllers/index.ts @@ -0,0 +1 @@ +export * from './privacy-policy.controller'; diff --git a/src/privacy-policy/controllers/privacy-policy.controller.ts b/src/privacy-policy/controllers/privacy-policy.controller.ts new file mode 100644 index 0000000..621a63c --- /dev/null +++ b/src/privacy-policy/controllers/privacy-policy.controller.ts @@ -0,0 +1,29 @@ +import { Controller, Get, HttpStatus } from '@nestjs/common'; +import { ApiOperation, ApiTags } from '@nestjs/swagger'; +import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; +import { ControllerRoute } from '@app/common/constants/controller-route'; // Assuming this is where the routes are defined +import { PrivacyPolicyService } from '../services'; + +@ApiTags('Privacy Policy Module') +@Controller({ + version: EnableDisableStatusEnum.ENABLED, + path: ControllerRoute.PRIVACY_POLICY.ROUTE, +}) +export class PrivacyPolicyController { + constructor(private readonly privacyPolicyService: PrivacyPolicyService) {} + + @Get() + @ApiOperation({ + summary: ControllerRoute.PRIVACY_POLICY.ACTIONS.FETCH_POLICY_SUMMARY, + description: + ControllerRoute.PRIVACY_POLICY.ACTIONS.FETCH_POLICY_DESCRIPTION, + }) + async fetchPrivacyPolicy() { + const htmlContent = await this.privacyPolicyService.fetchPrivacyPolicy(); + return { + statusCode: HttpStatus.OK, + message: 'Privacy policy fetched successfully', + data: htmlContent, + }; + } +} diff --git a/src/privacy-policy/privacy-policy.module.ts b/src/privacy-policy/privacy-policy.module.ts new file mode 100644 index 0000000..75da19c --- /dev/null +++ b/src/privacy-policy/privacy-policy.module.ts @@ -0,0 +1,12 @@ +import { DeviceRepositoryModule } from '@app/common/modules/device'; +import { Module } from '@nestjs/common'; +import { ConfigModule } from '@nestjs/config'; +import { PrivacyPolicyController } from './controllers'; +import { PrivacyPolicyService } from './services'; + +@Module({ + imports: [ConfigModule, DeviceRepositoryModule], + controllers: [PrivacyPolicyController], + providers: [PrivacyPolicyService], +}) +export class PrivacyPolicyModule {} diff --git a/src/privacy-policy/services/index.ts b/src/privacy-policy/services/index.ts new file mode 100644 index 0000000..9866974 --- /dev/null +++ b/src/privacy-policy/services/index.ts @@ -0,0 +1 @@ +export * from './privacy-policy.service'; diff --git a/src/privacy-policy/services/privacy-policy.service.ts b/src/privacy-policy/services/privacy-policy.service.ts new file mode 100644 index 0000000..9c347b8 --- /dev/null +++ b/src/privacy-policy/services/privacy-policy.service.ts @@ -0,0 +1,30 @@ +import { Injectable } from '@nestjs/common'; +import * as fs from 'fs'; +import * as path from 'path'; + +@Injectable() +export class PrivacyPolicyService { + async fetchPrivacyPolicy(): Promise { + const projectRoot = process.cwd(); + + const filePath = path.join( + projectRoot, + 'libs', + 'common', + 'src', + 'constants', + 'privacy-policy.html', + ); + + // Ensure the file exists + if (!fs.existsSync(filePath)) { + throw new Error(`File not found: ${filePath}`); + } + + let htmlContent = fs.readFileSync(filePath, 'utf-8'); + + htmlContent = htmlContent.replace(/(\r\n|\n|\r)/gm, ''); // Removes newlines + + return htmlContent; + } +}