-
Notifications
You must be signed in to change notification settings - Fork 182
fix: replace uuid package with Node.js crypto.randomUUID() for Render… #845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds a new backend environment backup file. Updates ESLint to disable several TypeScript/no-unused-vars rules. Adjusts build and postinstall scripts; removes uuid and @types/uuid dependencies. Replaces uuid.v4 usage with crypto.randomUUID() across multiple middlewares and services. No API or control-flow changes. Changes
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Frontend CI/CD Pipeline Completed Successfully!
Ready for review and deployment! 🚀 |
1 similar comment
✅ Frontend CI/CD Pipeline Completed Successfully!
Ready for review and deployment! 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/package.json (1)
62-62
: Inconsistent: uuid still present in devDependencies.The PR aims to replace the uuid package with Node.js built-in
crypto.randomUUID()
, but uuid remains in devDependencies. This creates confusion about whether the package is still needed.If uuid is truly no longer needed (as indicated by the PR title and other changes), remove it entirely:
"ts-node": "^10.9.2", - "typescript": "^5.8.3", - "uuid": "^8.3.2" + "typescript": "^5.8.3"If it's kept for testing purposes, document why it's needed in devDependencies.
♻️ Duplicate comments (5)
backend/src/middlewares/auth.middleware.ts (1)
23-24
: Same code duplication issue as other files.This file has the same duplicated
const uuidv4 = () => require('crypto').randomUUID()
pattern mentioned in the review of backend/src/services/auth.service.ts.Refer to the review comment on backend/src/services/auth.service.ts (lines 20-21) for the recommended solution to create a centralized UUID utility.
backend/src/middlewares/role.middleware.ts (1)
10-11
: Same code duplication issue as other files.This file has the same duplicated
const uuidv4 = () => require('crypto').randomUUID()
pattern.Refer to the review comment on backend/src/services/auth.service.ts (lines 20-21) for the recommended solution.
backend/src/middlewares/admin-api-key.middleware.ts (1)
271-272
: Move import to top of file and avoid duplication.The uuid helper definition is at the bottom of the file (after all function definitions), which is unconventional. TypeScript allows this due to hoisting, but it hurts readability.
- For consistency, move this import to the top with other imports.
- Better yet, use the centralized UUID utility suggested in the review of backend/src/services/auth.service.ts (lines 20-21).
Apply this diff:
import { supabase } from "@/lib/supabase/supabase"; +import { generateUUID as uuidv4 } from "@/utils/uuid.utils"; -// Import required dependencies -import { supabase } from "@/lib/supabase/supabase"; -// import { v4 as uuidv4 } from "uuid"; -const uuidv4 = () => require('crypto').randomUUID();backend/src/services/admin-integration.service.ts (1)
32-33
: Same code duplication issue as other files.This file has the same duplicated
const uuidv4 = () => require('crypto').randomUUID()
pattern.Refer to the review comment on backend/src/services/auth.service.ts (lines 20-21) for the recommended solution.
backend/src/middlewares/logger.middleware.ts (1)
5-6
: Optimize the UUID implementation.The same performance issue exists here:
require('crypto')
is called on every UUID generation. This should be optimized as suggested in the previous file.Apply the same fix as recommended for
admin-rate-limit.middleware.ts
:-// import { v4 as uuidv4 } from 'uuid'; -const uuidv4 = () => require('crypto').randomUUID(); +import { randomUUID } from 'crypto'; +const uuidv4 = randomUUID;Or better yet, create a shared utility module and import from there to eliminate duplication across all affected files.
🧹 Nitpick comments (1)
backend/package.json (1)
8-8
: CI and local Node.js versions satisfy crypto.randomUUID() requirements. Workflows use Node 18.x/20.x and .nvmrc is set to 20, all above the 14.17.0 minimum. Consider adding"engines": { "node": ">=14.17.0" }
to backend/package.json for clarity.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
backend/package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (10)
backend/.env.backup
(1 hunks)backend/eslint.config.js
(1 hunks)backend/package.json
(1 hunks)backend/src/middlewares/admin-api-key.middleware.ts
(1 hunks)backend/src/middlewares/admin-rate-limit.middleware.ts
(1 hunks)backend/src/middlewares/auth.middleware.ts
(1 hunks)backend/src/middlewares/logger.middleware.ts
(1 hunks)backend/src/middlewares/role.middleware.ts
(1 hunks)backend/src/services/admin-integration.service.ts
(1 hunks)backend/src/services/auth.service.ts
(1 hunks)
🧰 Additional context used
🪛 dotenv-linter (3.3.0)
backend/.env.backup
[warning] 9-9: [UnorderedKey] The SUPABASE_URL key should go before the WALLET_ENCRYPTION_KEY key
(UnorderedKey)
[warning] 10-10: [UnorderedKey] The SUPABASE_SERVICE_ROLE_KEY key should go before the SUPABASE_URL key
(UnorderedKey)
[warning] 11-11: [UnorderedKey] The SUPABASE_ANON_KEY key should go before the SUPABASE_SERVICE_ROLE_KEY key
(UnorderedKey)
[warning] 17-17: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
[warning] 20-20: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
[warning] 26-26: [UnorderedKey] The JWT_EXPIRES_IN key should go before the JWT_SECRET key
(UnorderedKey)
[warning] 27-27: [UnorderedKey] The JWT_REFRESH_EXPIRES_IN key should go before the JWT_SECRET key
(UnorderedKey)
[warning] 33-33: [DuplicatedKey] The WALLET_ENCRYPTION_KEY key is duplicated
(DuplicatedKey)
[warning] 45-45: [UnorderedKey] The STELLAR_HORIZON_URL key should go before the STELLAR_NETWORK key
(UnorderedKey)
[warning] 46-46: [UnorderedKey] The SOROBAN_RPC_URL key should go before the STELLAR_HORIZON_URL key
(UnorderedKey)
[warning] 47-47: [UnorderedKey] The NETWORK_PASSPHRASE key should go before the SOROBAN_RPC_URL key
(UnorderedKey)
[warning] 53-53: [UnorderedKey] The ESCROW_CONTRACT_ID key should go before the ESCROW_FACTORY_CONTRACT_ID key
(UnorderedKey)
[warning] 55-55: [UnorderedKey] The FEE_MANAGER_CONTRACT_ID key should go before the USER_REGISTRY_CONTRACT_ID key
(UnorderedKey)
[warning] 56-56: [UnorderedKey] The DISPUTE_CONTRACT_ID key should go before the ESCROW_CONTRACT_ID key
(UnorderedKey)
[warning] 57-57: [UnorderedKey] The PUBLICATION_CONTRACT_ID key should go before the USER_REGISTRY_CONTRACT_ID key
(UnorderedKey)
[warning] 58-58: [UnorderedKey] The RATING_CONTRACT_ID key should go before the USER_REGISTRY_CONTRACT_ID key
(UnorderedKey)
[warning] 59-59: [UnorderedKey] The REPUTATION_NFT_CONTRACT_ID key should go before the USER_REGISTRY_CONTRACT_ID key
(UnorderedKey)
[warning] 62-62: [DuplicatedKey] The WALLET_ENCRYPTION_KEY key is duplicated
(DuplicatedKey)
[warning] 64-64: [ExtraBlankLine] Extra blank line detected
(ExtraBlankLine)
[warning] 70-70: [DuplicatedKey] The USER_REGISTRY_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 74-74: [UnorderedKey] The STELLAR_ADMIN_ADDRESS key should go before the STELLAR_ADMIN_SECRET_KEY key
(UnorderedKey)
[warning] 77-77: [DuplicatedKey] The STELLAR_NETWORK key is duplicated
(DuplicatedKey)
[warning] 79-79: [UnorderedKey] The STELLAR_NETWORK_PASSPHRASE key should go before the STELLAR_RPC_URL key
(UnorderedKey)
[warning] 79-79: [ValueWithoutQuotes] This value needs to be surrounded in quotes
(ValueWithoutQuotes)
[warning] 82-82: [DuplicatedKey] The FEE_MANAGER_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 83-83: [DuplicatedKey] The ESCROW_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 83-83: [UnorderedKey] The ESCROW_CONTRACT_ID key should go before the FEE_MANAGER_CONTRACT_ID key
(UnorderedKey)
[warning] 84-84: [DuplicatedKey] The PUBLICATION_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 85-85: [DuplicatedKey] The RATING_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 86-86: [DuplicatedKey] The DISPUTE_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 86-86: [UnorderedKey] The DISPUTE_CONTRACT_ID key should go before the ESCROW_CONTRACT_ID key
(UnorderedKey)
[warning] 93-93: [DuplicatedKey] The USER_REGISTRY_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 96-96: [DuplicatedKey] The STELLAR_ADMIN_SECRET_KEY key is duplicated
(DuplicatedKey)
[warning] 97-97: [DuplicatedKey] The STELLAR_ADMIN_ADDRESS key is duplicated
(DuplicatedKey)
[warning] 97-97: [UnorderedKey] The STELLAR_ADMIN_ADDRESS key should go before the STELLAR_ADMIN_SECRET_KEY key
(UnorderedKey)
[warning] 100-100: [DuplicatedKey] The STELLAR_NETWORK key is duplicated
(DuplicatedKey)
[warning] 101-101: [DuplicatedKey] The STELLAR_RPC_URL key is duplicated
(DuplicatedKey)
[warning] 102-102: [DuplicatedKey] The STELLAR_NETWORK_PASSPHRASE key is duplicated
(DuplicatedKey)
[warning] 102-102: [UnorderedKey] The STELLAR_NETWORK_PASSPHRASE key should go before the STELLAR_RPC_URL key
(UnorderedKey)
[warning] 102-102: [ValueWithoutQuotes] This value needs to be surrounded in quotes
(ValueWithoutQuotes)
[warning] 105-105: [DuplicatedKey] The FEE_MANAGER_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 106-106: [DuplicatedKey] The ESCROW_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 106-106: [UnorderedKey] The ESCROW_CONTRACT_ID key should go before the FEE_MANAGER_CONTRACT_ID key
(UnorderedKey)
[warning] 107-107: [DuplicatedKey] The PUBLICATION_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 108-108: [DuplicatedKey] The RATING_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 109-109: [DuplicatedKey] The DISPUTE_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 109-109: [UnorderedKey] The DISPUTE_CONTRACT_ID key should go before the ESCROW_CONTRACT_ID key
(UnorderedKey)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build (20.x)
- GitHub Check: build (18.x)
🔇 Additional comments (1)
backend/src/middlewares/admin-rate-limit.middleware.ts (1)
5-5
: Node.js version compatibility verified. CI workflows test on Node.js 18.x and 20.x, both ≥v14.17, socrypto.randomUUID()
is supported.
# ================================= | ||
# PORT | ||
# ================================= | ||
PORT=4000 | ||
WALLET_ENCRYPTION_KEY=fLqD8olgulhHBw0FKphw8ocL9ZvDtKOsD5hnBjHjZhUs | ||
# ================================= | ||
# SUPABASE | ||
# ================================= | ||
SUPABASE_URL=https://oqutyzxqiabghsozpitt.supabase.co | ||
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9xdXR5enhxaWFiZ2hzb3pwaXR0Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc2MDAzNjI0OCwiZXhwIjoyMDc1NjEyMjQ4fQ.hb6tqe1bPR9TdiwapsYea9ZbOxyihHUPgrBOvrmHpLE | ||
SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9xdXR5enhxaWFiZ2hzb3pwaXR0Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjAwMzYyNDgsImV4cCI6MjA3NTYxMjI0OH0.490A5-axk85V6LOm1_pRATLiV_A7aVDJGT-86x7Pq0A | ||
|
||
# ================================= | ||
# DATABASE (Para Prisma / TypeORM) | ||
# ================================= | ||
# Connection pooling | ||
DATABASE_URL="postgresql://postgres.oqutyzxqiabghsozpitt:[email protected]:6543/postgres?pgbouncer=true" | ||
|
||
# Direct connection (para migraciones) | ||
DIRECT_URL="postgresql://postgres.oqutyzxqiabghsozpitt:[email protected]:5432/postgres" | ||
|
||
# ================================= | ||
# JWT CONFIG | ||
# ================================= | ||
JWT_SECRET=offerhub_super_secret_key_change_in_prod | ||
JWT_EXPIRES_IN=24h | ||
JWT_REFRESH_EXPIRES_IN=7d | ||
|
||
# ================================= | ||
# ENCRYPTION | ||
# ================================= | ||
ENCRYPTION_KEY=offerhub_2025_kevin_and_josue_costarica | ||
WALLET_ENCRYPTION_KEY=stellar_wallet_encryption_key_32chars_min | ||
|
||
# ================================= | ||
# GOOGLE OAUTH (opcional) | ||
# ================================= | ||
GOOGLE_CLIENT_ID= | ||
GOOGLE_CLIENT_SECRET= | ||
|
||
# ================================= | ||
# STELLAR NETWORK (solo Stellar testnet) | ||
# ================================= | ||
STELLAR_NETWORK=testnet | ||
STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org | ||
SOROBAN_RPC_URL=https://soroban-testnet.stellar.org:443 | ||
NETWORK_PASSPHRASE="Test SDF Network ; September 2015" | ||
|
||
# ================================= | ||
# SMART CONTRACTS (añadir IDs tras despliegue) | ||
# ================================= | ||
ESCROW_FACTORY_CONTRACT_ID= | ||
ESCROW_CONTRACT_ID= | ||
USER_REGISTRY_CONTRACT_ID= | ||
FEE_MANAGER_CONTRACT_ID= | ||
DISPUTE_CONTRACT_ID= | ||
PUBLICATION_CONTRACT_ID= | ||
RATING_CONTRACT_ID= | ||
REPUTATION_NFT_CONTRACT_ID= | ||
|
||
# Wallet Encryption Key (for invisible wallets) | ||
WALLET_ENCRYPTION_KEY=fLqD8olgulhHBw0FKphw8ocL9ZvDtKOsD5hnBjHjZhU= | ||
|
||
|
||
# ================================= | ||
# STELLAR BLOCKCHAIN - BACKEND | ||
# ================================= | ||
|
||
# User Registry Contract (para verificación) | ||
USER_REGISTRY_CONTRACT_ID=CCNJLJQ3MVJFCH2WANRBUZUQWP5FXVAW2IFGL2ZWG6O2ZEMCAIB5KDBZ | ||
|
||
# Admin Credentials (para firmar transacciones) | ||
STELLAR_ADMIN_SECRET_KEY=SB3QEVA5OCOQEQZVTA2PSAGT5HEA6SRXSQTP3TIWPDZTQMVSNBDTH6QE | ||
STELLAR_ADMIN_ADDRESS=GCNBMXP33TL2QPYMRTHVZOWNINZOGFJQEOPWVCYU3XDGOCH3TICREXLM | ||
|
||
# Network Configuration | ||
STELLAR_NETWORK=futurenet | ||
STELLAR_RPC_URL=https://rpc-futurenet.stellar.org:443 | ||
STELLAR_NETWORK_PASSPHRASE=Test SDF Future Network ; October 2022 | ||
|
||
# Otros Contratos (para futuras integraciones) | ||
FEE_MANAGER_CONTRACT_ID=CA4Y644PP6E4Z47RM2BNZ774RIVMLSTBNKAOJE76UEUFHQJPWWOK2WIJ | ||
ESCROW_CONTRACT_ID=CAJSICKVQXMC7FJLJE7W2KIFQKJM4DTWVJ6CKVKW2CM7OZIR4O2BVPOV | ||
PUBLICATION_CONTRACT_ID=CBWKAGSMAAVETQEQRMAWSUUUOJZSJE6RBYSMWIVHSU6YEJEHAESCUFT3 | ||
RATING_CONTRACT_ID=CC5PNC7RNHE4E7VWBJ7BY45GS2GPESFVDDLWVGCRHYPGJHN3JIBW6GBN | ||
DISPUTE_CONTRACT_ID=CDX5PUEYKS3QRGRQPCRUR7EKJBXKU77HPCFISCMXSZD7A4M235FOTXXF | ||
|
||
# ================================= | ||
# STELLAR BLOCKCHAIN - BACKEND | ||
# ================================= | ||
|
||
# User Registry Contract (para verificación) | ||
USER_REGISTRY_CONTRACT_ID=CCNJLJQ3MVJFCH2WANRBUZUQWP5FXVAW2IFGL2ZWG6O2ZEMCAIB5KDBZ | ||
|
||
# Admin Credentials (para firmar transacciones) | ||
STELLAR_ADMIN_SECRET_KEY=SB3QEVA5OCOQEQZVTA2PSAGT5HEA6SRXSQTP3TIWPDZTQMVSNBDTH6QE | ||
STELLAR_ADMIN_ADDRESS=GCNBMXP33TL2QPYMRTHVZOWNINZOGFJQEOPWVCYU3XDGOCH3TICREXLM | ||
|
||
# Network Configuration | ||
STELLAR_NETWORK=futurenet | ||
STELLAR_RPC_URL=https://rpc-futurenet.stellar.org:443 | ||
STELLAR_NETWORK_PASSPHRASE=Test SDF Future Network ; October 2022 | ||
|
||
# Otros Contratos | ||
FEE_MANAGER_CONTRACT_ID=CA4Y644PP6E4Z47RM2BNZ774RIVMLSTBNKAOJE76UEUFHQJPWWOK2WIJ | ||
ESCROW_CONTRACT_ID=CAJSICKVQXMC7FJLJE7W2KIFQKJM4DTWVJ6CKVKW2CM7OZIR4O2BVPOV | ||
PUBLICATION_CONTRACT_ID=CBWKAGSMAAVETQEQRMAWSUUUOJZSJE6RBYSMWIVHSU6YEJEHAESCUFT3 | ||
RATING_CONTRACT_ID=CC5PNC7RNHE4E7VWBJ7BY45GS2GPESFVDDLWVGCRHYPGJHN3JIBW6GBN | ||
DISPUTE_CONTRACT_ID=CDX5PUEYKS3QRGRQPCRUR7EKJBXKU77HPCFISCMXSZD7A4M235FOTXXF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRITICAL: Remove sensitive credentials from version control immediately.
This .env.backup
file contains sensitive production credentials including:
- Database connection strings with passwords (lines 17, 20)
- JWT secrets (line 25)
- Encryption keys (lines 5, 33, 62)
- Supabase service role keys (line 10)
- Admin wallet secret keys (lines 73, 96)
- API keys (line 11)
Immediate actions required:
- Remove this file from the repository immediately:
git rm backend/.env.backup
git commit -m "Remove sensitive credentials from version control"
-
Rotate ALL exposed credentials:
- Database passwords
- JWT secrets
- Encryption keys
- Supabase keys
- Admin wallet keys
-
Add to
.gitignore
:
+backend/.env.backup
+backend/.env.*
- Use
.env.example
instead with placeholder values:
# Database
DATABASE_URL="postgresql://user:password@host:port/database"
# JWT
JWT_SECRET=your_secret_here_change_in_production
Additional issues in this file:
- Line 5, 33, 62:
WALLET_ENCRYPTION_KEY
duplicated 3 times with different values - Line 70, 93:
USER_REGISTRY_CONTRACT_ID
duplicated - Lines 65-109: Entire configuration block duplicated
As per static analysis hints.
🧰 Tools
🪛 dotenv-linter (3.3.0)
[warning] 9-9: [UnorderedKey] The SUPABASE_URL key should go before the WALLET_ENCRYPTION_KEY key
(UnorderedKey)
[warning] 10-10: [UnorderedKey] The SUPABASE_SERVICE_ROLE_KEY key should go before the SUPABASE_URL key
(UnorderedKey)
[warning] 11-11: [UnorderedKey] The SUPABASE_ANON_KEY key should go before the SUPABASE_SERVICE_ROLE_KEY key
(UnorderedKey)
[warning] 17-17: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
[warning] 20-20: [QuoteCharacter] The value has quote characters (', ")
(QuoteCharacter)
[warning] 26-26: [UnorderedKey] The JWT_EXPIRES_IN key should go before the JWT_SECRET key
(UnorderedKey)
[warning] 27-27: [UnorderedKey] The JWT_REFRESH_EXPIRES_IN key should go before the JWT_SECRET key
(UnorderedKey)
[warning] 33-33: [DuplicatedKey] The WALLET_ENCRYPTION_KEY key is duplicated
(DuplicatedKey)
[warning] 45-45: [UnorderedKey] The STELLAR_HORIZON_URL key should go before the STELLAR_NETWORK key
(UnorderedKey)
[warning] 46-46: [UnorderedKey] The SOROBAN_RPC_URL key should go before the STELLAR_HORIZON_URL key
(UnorderedKey)
[warning] 47-47: [UnorderedKey] The NETWORK_PASSPHRASE key should go before the SOROBAN_RPC_URL key
(UnorderedKey)
[warning] 53-53: [UnorderedKey] The ESCROW_CONTRACT_ID key should go before the ESCROW_FACTORY_CONTRACT_ID key
(UnorderedKey)
[warning] 55-55: [UnorderedKey] The FEE_MANAGER_CONTRACT_ID key should go before the USER_REGISTRY_CONTRACT_ID key
(UnorderedKey)
[warning] 56-56: [UnorderedKey] The DISPUTE_CONTRACT_ID key should go before the ESCROW_CONTRACT_ID key
(UnorderedKey)
[warning] 57-57: [UnorderedKey] The PUBLICATION_CONTRACT_ID key should go before the USER_REGISTRY_CONTRACT_ID key
(UnorderedKey)
[warning] 58-58: [UnorderedKey] The RATING_CONTRACT_ID key should go before the USER_REGISTRY_CONTRACT_ID key
(UnorderedKey)
[warning] 59-59: [UnorderedKey] The REPUTATION_NFT_CONTRACT_ID key should go before the USER_REGISTRY_CONTRACT_ID key
(UnorderedKey)
[warning] 62-62: [DuplicatedKey] The WALLET_ENCRYPTION_KEY key is duplicated
(DuplicatedKey)
[warning] 64-64: [ExtraBlankLine] Extra blank line detected
(ExtraBlankLine)
[warning] 70-70: [DuplicatedKey] The USER_REGISTRY_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 74-74: [UnorderedKey] The STELLAR_ADMIN_ADDRESS key should go before the STELLAR_ADMIN_SECRET_KEY key
(UnorderedKey)
[warning] 77-77: [DuplicatedKey] The STELLAR_NETWORK key is duplicated
(DuplicatedKey)
[warning] 79-79: [UnorderedKey] The STELLAR_NETWORK_PASSPHRASE key should go before the STELLAR_RPC_URL key
(UnorderedKey)
[warning] 79-79: [ValueWithoutQuotes] This value needs to be surrounded in quotes
(ValueWithoutQuotes)
[warning] 82-82: [DuplicatedKey] The FEE_MANAGER_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 83-83: [DuplicatedKey] The ESCROW_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 83-83: [UnorderedKey] The ESCROW_CONTRACT_ID key should go before the FEE_MANAGER_CONTRACT_ID key
(UnorderedKey)
[warning] 84-84: [DuplicatedKey] The PUBLICATION_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 85-85: [DuplicatedKey] The RATING_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 86-86: [DuplicatedKey] The DISPUTE_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 86-86: [UnorderedKey] The DISPUTE_CONTRACT_ID key should go before the ESCROW_CONTRACT_ID key
(UnorderedKey)
[warning] 93-93: [DuplicatedKey] The USER_REGISTRY_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 96-96: [DuplicatedKey] The STELLAR_ADMIN_SECRET_KEY key is duplicated
(DuplicatedKey)
[warning] 97-97: [DuplicatedKey] The STELLAR_ADMIN_ADDRESS key is duplicated
(DuplicatedKey)
[warning] 97-97: [UnorderedKey] The STELLAR_ADMIN_ADDRESS key should go before the STELLAR_ADMIN_SECRET_KEY key
(UnorderedKey)
[warning] 100-100: [DuplicatedKey] The STELLAR_NETWORK key is duplicated
(DuplicatedKey)
[warning] 101-101: [DuplicatedKey] The STELLAR_RPC_URL key is duplicated
(DuplicatedKey)
[warning] 102-102: [DuplicatedKey] The STELLAR_NETWORK_PASSPHRASE key is duplicated
(DuplicatedKey)
[warning] 102-102: [UnorderedKey] The STELLAR_NETWORK_PASSPHRASE key should go before the STELLAR_RPC_URL key
(UnorderedKey)
[warning] 102-102: [ValueWithoutQuotes] This value needs to be surrounded in quotes
(ValueWithoutQuotes)
[warning] 105-105: [DuplicatedKey] The FEE_MANAGER_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 106-106: [DuplicatedKey] The ESCROW_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 106-106: [UnorderedKey] The ESCROW_CONTRACT_ID key should go before the FEE_MANAGER_CONTRACT_ID key
(UnorderedKey)
[warning] 107-107: [DuplicatedKey] The PUBLICATION_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 108-108: [DuplicatedKey] The RATING_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 109-109: [DuplicatedKey] The DISPUTE_CONTRACT_ID key is duplicated
(DuplicatedKey)
[warning] 109-109: [UnorderedKey] The DISPUTE_CONTRACT_ID key should go before the ESCROW_CONTRACT_ID key
(UnorderedKey)
'@typescript-eslint/no-unused-vars': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-require-imports': 'off', | ||
'no-console': 'off', | ||
'no-undef': 'off', | ||
'no-unused-vars': 'off', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid broadly disabling linting rules.
Disabling @typescript-eslint/no-unused-vars
, no-unused-vars
, @typescript-eslint/no-explicit-any
, and @typescript-eslint/no-require-imports
globally can hide legitimate issues like dead code, type safety violations, and improper imports.
Consider:
- Use inline comments (
// eslint-disable-next-line
) for specific cases where these rules conflict with the crypto.randomUUID() pattern. - Limit
no-require-imports
exceptions to files that specifically needrequire('crypto')
. - Keep
no-unused-vars
enabled to catch dead code.
Apply this diff to re-enable the rules and use targeted exceptions:
rules: {
...tseslint.configs.recommended.rules,
- '@typescript-eslint/no-unused-vars': 'off',
- '@typescript-eslint/no-explicit-any': 'off',
- '@typescript-eslint/no-require-imports': 'off',
+ '@typescript-eslint/no-unused-vars': ['error', {
+ 'argsIgnorePattern': '^_',
+ 'varsIgnorePattern': '^_'
+ }],
+ '@typescript-eslint/no-explicit-any': 'warn',
'no-console': 'off',
'no-undef': 'off',
- 'no-unused-vars': 'off',
},
Then add inline exceptions in files using the crypto require pattern:
// eslint-disable-next-line @typescript-eslint/no-require-imports
const uuidv4 = () => require('crypto').randomUUID();
"scripts": { | ||
"dev": "ts-node -r tsconfig-paths/register src/index.ts", | ||
"build": "tsc && tsc-alias", | ||
"build": "tsc --noEmitOnError false && tsc-alias", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove --noEmitOnError false
flag to prevent builds with TypeScript errors.
Setting --noEmitOnError false
allows the build to succeed even when TypeScript detects type errors, which can lead to runtime failures in production.
Apply this diff to restore proper type checking:
- "build": "tsc --noEmitOnError false && tsc-alias",
+ "build": "tsc && tsc-alias",
If specific files have type issues that need to be addressed separately, fix those issues directly rather than bypassing type checking.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"build": "tsc --noEmitOnError false && tsc-alias", | |
"build": "tsc && tsc-alias", |
🤖 Prompt for AI Agents
In backend/package.json around line 8, the build script currently includes the
flag `--noEmitOnError false` which disables TypeScript's fail-on-error behavior;
remove that flag (or set it to `--noEmitOnError`/`--noEmitOnError true`) so the
build fails on type errors and update the script to just run `tsc` (or `tsc
--noEmitOnError`) followed by `tsc-alias`; do not reintroduce a false value —
fix any underlying type errors instead.
// import { v4 as uuidv4 } from "uuid"; | ||
const uuidv4 = () => require('crypto').randomUUID(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optimize the UUID implementation and eliminate code duplication.
The current pattern const uuidv4 = () => require('crypto').randomUUID()
calls require('crypto')
on every UUID generation, which is inefficient. Additionally, this exact pattern is duplicated across at least 7 files (per the AI summary), violating the DRY principle.
Immediate fix for this file:
-// import { v4 as uuidv4 } from "uuid";
-const uuidv4 = () => require('crypto').randomUUID();
+import { randomUUID } from 'crypto';
+const uuidv4 = randomUUID;
Recommended long-term solution:
Create a shared utility module (e.g., backend/src/utils/uuid.ts
):
import { randomUUID } from 'crypto';
export const uuidv4 = randomUUID;
Then import from the utility across all files:
import { uuidv4 } from '@/utils/uuid';
This centralizes the UUID generation logic, improves performance, and makes future changes (e.g., adding UUID validation helpers) easier to implement.
🤖 Prompt for AI Agents
In backend/src/middlewares/admin-rate-limit.middleware.ts around lines 4-5, the
file defines uuidv4 as a function that calls require('crypto').randomUUID() on
every invocation which is inefficient and duplicated across multiple files;
replace this pattern by importing a single shared utility that exports the
crypto randomUUID once. Create backend/src/utils/uuid.ts that imports randomUUID
from 'crypto' and re-exports it as uuidv4, then update this file to import {
uuidv4 } from '@/utils/uuid' (or the correct relative path) and remove the
inline require to eliminate duplication and improve performance.
// import { v4 as uuidv4 } from "uuid"; | ||
const uuidv4 = () => require('crypto').randomUUID(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Eliminate code duplication by creating a shared UUID utility.
The pattern const uuidv4 = () => require('crypto').randomUUID()
is duplicated across at least 7 files in this PR (auth.service.ts, admin-integration.service.ts, auth.middleware.ts, role.middleware.ts, admin-api-key.middleware.ts, logger.middleware.ts, and admin-rate-limit.middleware.ts).
Create a centralized utility file to avoid duplication and improve type safety:
Create backend/src/utils/uuid.utils.ts
:
/**
* UUID generation utility using Node.js built-in crypto
* Requires Node.js 14.17.0+ or 15.6.0+
*/
export function generateUUID(): string {
return require('crypto').randomUUID() as string;
}
Then update this file:
-// import { v4 as uuidv4 } from "uuid";
-const uuidv4 = () => require('crypto').randomUUID();
+import { generateUUID as uuidv4 } from "@/utils/uuid.utils";
Apply the same change to all other files using this pattern. This approach:
- Eliminates duplication
- Centralizes the Node.js version dependency
- Improves type safety
- Makes future changes easier (single location to update)
🤖 Prompt for AI Agents
In backend/src/services/auth.service.ts around lines 20 to 21, the inline uuidv4
implementation is duplicated across multiple files; create a centralized utility
at backend/src/utils/uuid.utils.ts that exports a typed generateUUID(): string
which returns require('crypto').randomUUID(), then replace the local const
uuidv4 = () => require('crypto').randomUUID() with an import { generateUUID }
from '../utils/uuid.utils' (adjust relative path) and use generateUUID() where
needed; apply the same replacement in admin-integration.service.ts,
auth.middleware.ts, role.middleware.ts, admin-api-key.middleware.ts,
logger.middleware.ts, and admin-rate-limit.middleware.ts.
✅ Frontend CI/CD Pipeline Completed Successfully!
Ready for review and deployment! 🚀 |
… compatibility
📝 Pull Request Title
🛠️ Issue
📚 Description
✅ Changes applied
🔍 Evidence/Media (screenshots/videos)
Summary by CodeRabbit