feat:[BACKEND] Implement QR Code / Barcode Generator Module #296#334
Merged
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom Oct 2, 2025
Conversation
|
Someone 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.
Title
Add QR/Barcode generation and retrieval for assets
Description
This PR introduces a new QR/Barcode module that allows each asset to have a unique QR code and barcode for physical tracking and scanning. The implementation provides the ability to generate, store, retrieve, and verify codes.
Key Changes
Added new columns to the Asset entity for storing QR and barcode data (qrCodeBase64, barcodeBase64, qrCodeFilename, barcodeFilename).
Created QrBarcodeService with methods to:
Generate QR codes as base64 data URLs.
Generate barcodes using bwip-js.
Persist base64 representations or save PNG files to disk.
Retrieve stored codes for a given asset.
Verify scanned payloads against existing assets.
Added QrBarcodeController with endpoints to:
Generate and store codes for an asset (POST /assets/:id/generate-code).
Retrieve stored codes as JSON (GET /assets/:id/codes).
Fetch QR or barcode images directly (GET /assets/:id/code/qr, GET /assets/:id/code/barcode).
Verify scanned payloads (GET /assets/verify?payload=...).
Created database migration to add new code-related columns to the assets table.
Integrated the new module into AppModule.
Expected Behavior
When an asset is created or updated, codes can be generated and stored via the API.
Codes are stored in the database as base64 strings, with optional file saving to disk.
Codes can be retrieved via dedicated endpoints.
Verification endpoint ensures scanned codes correspond to valid assets.
Notes
Images are currently stored as base64 in the database; this can be extended to cloud storage if needed.
QR codes embed a JSON payload containing the asset id and name.
Barcode generation uses Code128 format by default.