Implement user transfer API with JWT authentication and Prisma#9
Implement user transfer API with JWT authentication and Prisma#9gustavoSutil wants to merge 1 commit into
Conversation
…integration - Added new endpoints for user transfer functionality in main.ts - Integrated Prisma for database operations with SQLite as the datasource - Created Prisma schema for User, AuditLog, and Notification models - Introduced types for transfer requests and responses - Added JWT decoding and error handling for authentication - Implemented notification scheduling for pending transfers - Updated package.json to include Prisma and related dependencies
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
User description
…integration
PR Type
Enhancement
Description
Implemented user transfer API endpoint.
Integrated Prisma for database operations.
Added JWT authentication and validation.
Defined API request and response types.
Scheduled notifications for transfers.
Diagram Walkthrough
File Walkthrough
main.ts
Implement User Transfer API Endpoint with Express and Prismasrc/main.ts
/api/v1/users/:userId/transferforuser-to-user money transfers.
specific error codes for invalid tokens.
data, updating balances, and scheduling notifications.
user existence, password, amount, and sufficient balance.
types.ts
Define API Request, Response, and JWT Payload Typessrc/types.ts
TransferRequestinterface for incoming transfer requestbodies.
TransferResponseinterface for successful transfer responses,including debug information.
ErrorResponseinterface for standardized error messages.JwtPayloadinterface to type decoded JWT tokens.prismaClient.ts
Initialize and Export Prisma Clientsrc/prismaClient.ts
PrismaClientinstance.application.
schema.prisma
Define Prisma Database Schema for User, AuditLog, and Notificationprisma/schema.prisma
URL.
Usermodel with fields likeid,email,passwordHash,balance, androle.AuditLogmodel to record user actions withuserId,action, andpayload.Notificationmodel for user alerts, includinguserId,title, andbody.package.json
Add Prisma, Express, and JWT Dependencies and Scriptspackage.json
prisma:generateanddb:pushfor Prisma CLIoperations.
@prisma/client,express, andjsonwebtokenas new productiondependencies.
@types/express,@types/jsonwebtoken, andprismaas newdevelopment dependencies.
Express.js.