From 6febdeabbce5fe6dd944cf78a4c00198cf7a1adc Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 16:58:09 +0700 Subject: [PATCH 01/11] Add env.validation.ts --- apps/backend/src/config/env.validation.ts | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 apps/backend/src/config/env.validation.ts diff --git a/apps/backend/src/config/env.validation.ts b/apps/backend/src/config/env.validation.ts new file mode 100644 index 0000000..4f92d2b --- /dev/null +++ b/apps/backend/src/config/env.validation.ts @@ -0,0 +1,60 @@ +import * as Joi from 'joi'; + +export const envValidationSchema = Joi.object({ + // App + NODE_ENV: Joi.string() + .valid('development', 'production', 'test') + .default('development'), + PORT: Joi.number().default(4000), + + // Database + DATABASE_URL: Joi.string() + .uri() + .required() + .messages({ + 'string.uri': 'DATABASE_URL must be a valid URI (e.g., postgresql://user:pass@localhost:5432/db)', + 'any.required': 'DATABASE_URL is required. Set it in your .env file.', + }), + + // JWT + JWT_SECRET: Joi.string() + .min(32) + .required() + .messages({ + 'string.min': 'JWT_SECRET must be at least 32 characters long', + 'any.required': 'JWT_SECRET is required. Generate one with: openssl rand -base64 32', + }), + + // Stellar + STELLAR_NETWORK: Joi.string() + .valid('public', 'testnet', 'futurenet') + .default('testnet') + .messages({ + 'any.only': 'STELLAR_NETWORK must be one of: public, testnet, futurenet', + }), + + STELLAR_HORIZON_URL: Joi.string() + .uri() + .optional() + .default('https://horizon-testnet.stellar.org'), + + SOROBAN_RPC_URL: Joi.string() + .uri() + .optional() + .default('https://rpc-futurenet.stellar.org'), + + // Contract + BOUNTY_CONTRACT_ID: Joi.string() + .optional() + .allow('') + .pattern(/^C[A-Z2-7]{55}$/) + .messages({ + 'string.pattern.base': 'BOUNTY_CONTRACT_ID must be a valid Stellar contract ID (starts with C, 56 chars)', + }), + + // Frontend URL (for CORS) + FRONTEND_URL: Joi.string() + .uri() + .optional() + .default('http://localhost:3000'), +}); From baa6d35e21eb878b2060d7ae83f9f59c269aeaa5 Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 16:58:11 +0700 Subject: [PATCH 02/11] Add env.validation.ts From f21db377a04cb3630762c05edc7b0def0ad30c64 Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 16:58:17 +0700 Subject: [PATCH 03/11] Add .env.example --- apps/backend/.env.example | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 apps/backend/.env.example diff --git a/apps/backend/.env.example b/apps/backend/.env.example new file mode 100644 index 0000000..ffe8542 --- /dev/null +++ b/apps/backend/.env.example @@ -0,0 +1,24 @@ +# ============================================================ +# StellarBounty Backend Configuration +# ============================================================ + +# App +NODE_ENV=development +PORT=4000 + +# Database (required) +DATABASE_URL=postgresql://user:password@localhost:5432/stellarbounty + +# JWT (required - generate with: openssl rand -base64 32) +JWT_SECRET=your-super-secret-key-at-least-32-chars-long + +# Stellar Network +STELLAR_NETWORK=testnet +STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org +SOROBAN_RPC_URL=https://rpc-futurenet.stellar.org + +# Smart Contract (optional for development) +BOUNTY_CONTRACT_ID= + +# Frontend URL (for CORS) +FRONTEND_URL=http://localhost:3000 From 6bb3335e36a5da1ae5e6757aafc455e87ba206ab Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 16:58:27 +0700 Subject: [PATCH 04/11] Add env.validation.ts From 096236e6d6672b52bf498424c97cb7df51447379 Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 16:58:29 +0700 Subject: [PATCH 05/11] Add .env.example From f867877210d6045f1502d7b01fb7a4418a4d6e5c Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 17:17:38 +0700 Subject: [PATCH 06/11] Add env.validation.ts From 7f4ec1bd191417e914ae19ff0b8dc940adcacecd Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 17:17:40 +0700 Subject: [PATCH 07/11] Add .env.example From 6b1b6cb9a0010d3422532c8a165f71a7db516a2b Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 17:49:46 +0700 Subject: [PATCH 08/11] Add env.validation.ts From cb8b413816707e4aed22577f124631e0393365b9 Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 17:49:48 +0700 Subject: [PATCH 09/11] Add .env.example From f0949bdde4b713f77f327fd9d1114440fb98d491 Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 17:54:22 +0700 Subject: [PATCH 10/11] Add env.validation.ts From 44f1aefee8a224a798d86a8e9b1ecb29fb4cebcb Mon Sep 17 00:00:00 2001 From: Gops <154628241+nonoto999t@users.noreply.github.com> Date: Tue, 19 May 2026 17:54:23 +0700 Subject: [PATCH 11/11] Add .env.example