Skip to content

Wallet Module

Manages shared financial containers (wallets), balances, and wallet membership operations.

  • POST /api/v1/wallet
  • GET /api/v1/wallet
  • PUT /api/v1/wallet/:walletId
  • DELETE /api/v1/wallet/:walletId
  • POST /api/v1/wallet/:walletId/members
  • DELETE /api/v1/wallet/:walletId/members/:memberId
  • Create/update wallet: name 3-20 chars, currency in supported ISO list, balance >= 0.
  • Add member: valid email required.
  • Schema file: backend/src/Shared/Schemas/walletSchema.ts.
RouteControllerUse caseRepositoryRoute file trace
POST /walletWalletController.createCreateWalletImplWalletRepositoryImplbackend/src/Presentation/Routes/WalletRoutes.ts
GET /walletWalletController.listUserWalletsGetUserWalletsImplWalletRepositoryImplbackend/src/Presentation/Routes/WalletRoutes.ts
PUT /wallet/:walletIdWalletController.editEditWalletImplWalletRepositoryImplbackend/src/Presentation/Routes/WalletRoutes.ts
DELETE /wallet/:walletIdWalletController.deleteDeleteWalletImplWalletRepositoryImplbackend/src/Presentation/Routes/WalletRoutes.ts
POST /wallet/:walletId/membersWalletController.addMemberAddWalletMemberImplWalletRepositoryImpl, UserRepositoryImplbackend/src/Presentation/Routes/WalletRoutes.ts
DELETE /wallet/:walletId/members/:memberIdWalletController.deleteMemberDeleteWalletMemberImplWalletRepositoryImplbackend/src/Presentation/Routes/WalletRoutes.ts

Controller: backend/src/Presentation/Controllers/WalletController.ts.

  • USER_NOT_AUTHENTICATED (401).
  • WALLET_NOT_FOUND (404).
  • WALLET_ALREADY_EXISTS (400).
  • INSUFFICIENT_PERMISSIONS (403).
  • E2E file: backend/src/tests/e2e/wallet/wallet-crud.e2e.test.ts.
  • Unit examples:
    • backend/src/tests/unit/add-wallet-member-impl.test.ts
Terminal window
curl -X POST "https://budgeti-backend.johandercampos.com/api/v1/wallet" \
-H "Authorization: Bearer <jwt>" \
-H "Content-Type: application/json" \
-d '{
"name": "Main Wallet",
"currency": "USD",
"balance": 1500
}'
{
"code": "WALLET_CREATED",
"message": "Wallet created successfully",
"wallet": {
"id": "wlt_123",
"name": "Main Wallet",
"currency": "USD",
"balance": 1500,
"ownerId": "usr_123"
}
}
{
"code": "WALLET_NOT_FOUND",
"message": "Wallet not found",
"error": "Wallet not found"
}
// WalletController.create
const userId = req.user?.userId ?? req.userId;
const created = await createWalletUseCase.execute(req.body, userId);
return res.status(201).json({
...buildSuccessResponse(SuccessCodes.WALLET_CREATED),
wallet: created,
});