feat(compliance): implement license and compliance module#335
Merged
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom Oct 2, 2025
Merged
Conversation
|
@Tinna23 is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: feat(compliance): implement license and compliance module
Closes #294
Description
This pull request introduces a new
LicensesModuleto track and manage compliance documents and licenses associated with assets (e.g., vehicle registrations, software licenses).The core of this feature is a proactive alerting system. A scheduled job runs daily to automatically detect licenses that are nearing their expiration date and triggers an event to notify the relevant parties. This transforms compliance management from a reactive, manual process into an automated, proactive one.
Implementation Details
Core Components
LicenseEntity: A new TypeORM entity that defines thelicensestable. It stores theassetId,licenseType,expiryDate, adocumentUrl, and anisExpiryNotifiedflag to prevent duplicate alerts.LicensesService: Provides the core CRUD logic for managing license records and includes a specific method,findLicensesNearingExpiry, to query for licenses expiring within the next 30 days.LicenseExpiryTask: A scheduled job (cron job) using@nestjs/schedulethat runs every day at 9 AM. It calls the service to find expiring licenses and emits alicense.nearing_expiryevent for each one, which can be handled by a separate notifications module.LicensesController: Exposes RESTful API endpoints for creating, retrieving, and deleting license records.Workflow
POST /licensesendpoint.LicenseExpiryTaskruns daily.license.nearing_expiryevent and then updates the license'sisExpiryNotifiedflag totrue.NotificationsModule(listening for this event) can then send an email or in-app alert to the asset owner or administrator.How to Test
1. Setup
npm install @nestjs/schedule.LicensesModule,ScheduleModule.forRoot(), andEventEmitterModule.forRoot()into your mainapp.module.ts.licensestable.2. Test CRUD Functionality
POSTrequest to/licenseswith a valid request body, including anexpiryDateset for two weeks from now.{ "assetId": "asset-123", "licenseType": "Vehicle Registration", "expiryDate": "2025-10-16", "documentUrl": "[http://example.com/doc.pdf](http://example.com/doc.pdf)" }GETrequest to/licenses/asset/asset-123. Verify the new license is in the returned array.3. Test the Scheduled Job
LicenseExpiryTaskfrom@Cron(CronExpression.EVERY_DAY_AT_9AM)to@Cron(CronExpression.EVERY_10_SECONDS).isExpiryNotifiedflag in the database for that license should now betrue.