implementation of API to record buying of an impact product#14
Open
shamoo53 wants to merge 1 commit intoRegen-Bazaar:mainfrom
Open
implementation of API to record buying of an impact product#14shamoo53 wants to merge 1 commit intoRegen-Bazaar:mainfrom
shamoo53 wants to merge 1 commit intoRegen-Bazaar:mainfrom
Conversation
Member
There was a problem hiding this comment.
package-lock.json can be removed
pratiksardar
approved these changes
Aug 13, 2025
Member
pratiksardar
left a comment
There was a problem hiding this comment.
LGTM , how can we try these out via postman or something ?
or how can we deploy it ? do you think supabase will be fine?
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.
📝 Description
This pull request introduces a new API feature to securely and efficiently record the purchase of an impact product (RWIP) in the system. The implementation ensures that every RWIP purchase is captured with complete transaction details, NFT metadata, and proper authentication, providing a solid foundation for future analytics, ownership tracking, and extensibility.
✅ Key Changes
Database Model Extension
The existing Transaction Mongoose schema has been extended to support NFT-specific details through a new nft subdocument.
The nft object includes:
tokenId: Unique NFT identifier.
name: NFT name (e.g., RWIP #1).
description: NFT description.
image: NFT image URL.
metadata: Flexible object for additional NFT information.
Dedicated Controller (rwipController.js)
Introduced a new purchaseRWIP function to handle RWIP purchase recording.
Responsibilities:
Validate required fields: buyer, seller, price, NFT details, transaction hash, etc.
Create and store the transaction as a nft_transfer type in the database.
Return the saved transaction in the response.
New Route (rwip.js)
Added a new POST route: /api/rwip/purchase.
The route is secured with authentication middleware to ensure only authorized users can record purchases.
The route is registered in the main API router (src/routes/index.js).
API Documentation (Updated README.md)
A new "RWIP" section has been added to the documentation.
Includes:
Endpoint: POST /api/rwip/purchase
Required Fields: buyerAddress, sellerAddress, price, NFT details, etc.
Sample Request & Response provided for developer guidance.
🔄 How It Works
When a user successfully buys a RWIP, the frontend sends a POST request to /api/rwip/purchase with the complete transaction and NFT information.
The backend validates and records the purchase in the Transaction collection with the appropriate fields.
All relevant details are persisted, including:
Buyer address
Seller address
Transaction hash
Purchase date
Price
NFT details (name, tokenId, metadata, image, etc.)
🎯 Benefits
Ensures traceability and accountability for every RWIP purchase.
Clean separation of concerns by introducing a dedicated controller and route.
Future-proof design for additional impact products or NFT integrations.
Strengthens security by enforcing authentication on purchase actions.
✅ Checklist
Transaction model extended with NFT details
Dedicated controller created
New authenticated route added
API documentation updated
Closes #11