diff --git a/backend/migrations/20260107000001-add-requires-action-payment-status.js b/backend/migrations/20260107000001-add-requires-action-payment-status.js index d26f930..7fb813b 100644 --- a/backend/migrations/20260107000001-add-requires-action-payment-status.js +++ b/backend/migrations/20260107000001-add-requires-action-payment-status.js @@ -10,13 +10,9 @@ module.exports = { }, down: async (queryInterface, Sequelize) => { - // Note: PostgreSQL does not support removing values from ENUMs directly. - // The 'requires_action' value will remain in the enum but can be unused. - // To fully remove it would require recreating the enum and column, - // which is complex and risky for production data. console.log( "Note: PostgreSQL does not support removing ENUM values. " + - "'requires_action' will remain in the enum but will not be used." + "'requires_action' will remain in the enum but will not be used.", ); }, }; diff --git a/backend/migrations/20260108000001-add-on-hold-to-payout-status.js b/backend/migrations/20260108000001-add-on-hold-to-payout-status.js index 4e074cc..bd63340 100644 --- a/backend/migrations/20260108000001-add-on-hold-to-payout-status.js +++ b/backend/migrations/20260108000001-add-on-hold-to-payout-status.js @@ -9,10 +9,8 @@ module.exports = { }, down: async (queryInterface, Sequelize) => { - // Note: PostgreSQL doesn't support removing enum values directly - // This would require recreating the enum type console.log( - "Cannot remove enum value - manual intervention required if rollback needed" + "Cannot remove enum value - manual intervention required if rollback needed", ); }, }; diff --git a/backend/tests/setup.js b/backend/tests/setup.js index 893e31a..f7683c7 100644 --- a/backend/tests/setup.js +++ b/backend/tests/setup.js @@ -1,14 +1,14 @@ -process.env.NODE_ENV = 'test'; -process.env.JWT_SECRET = 'test-secret'; -process.env.DATABASE_URL = 'postgresql://test'; -process.env.GOOGLE_MAPS_API_KEY = 'test-key'; -process.env.STRIPE_SECRET_KEY = 'sk_test_key'; -process.env.CSRF_SECRET = 'test-csrf-secret-that-is-at-least-32-chars-long'; +process.env.NODE_ENV = "test"; +process.env.JWT_SECRET = "test-secret"; +process.env.DATABASE_URL = "db://test"; +process.env.GOOGLE_MAPS_API_KEY = "test-key"; +process.env.STRIPE_SECRET_KEY = "sk_test_key"; +process.env.CSRF_SECRET = "test-csrf-secret-that-is-at-least-32-chars-long"; // Silence console global.console = { ...console, log: jest.fn(), error: jest.fn(), - warn: jest.fn() + warn: jest.fn(), }; diff --git a/lambdas/conditionCheckReminder/README.md b/lambdas/conditionCheckReminder/README.md index 278cfc6..3cc92ec 100644 --- a/lambdas/conditionCheckReminder/README.md +++ b/lambdas/conditionCheckReminder/README.md @@ -4,12 +4,12 @@ Sends email reminders to owners and renters to complete condition checks at key ## Check Types -| Check Type | Recipient | Timing | -|------------|-----------|--------| -| `pre_rental_owner` | Owner | 24 hours before rental start | -| `rental_start_renter` | Renter | At rental start | -| `rental_end_renter` | Renter | At rental end | -| `post_rental_owner` | Owner | 24 hours after rental end | +| Check Type | Recipient | Timing | +| --------------------- | --------- | ---------------------------- | +| `pre_rental_owner` | Owner | 24 hours before rental start | +| `rental_start_renter` | Renter | At rental start | +| `rental_end_renter` | Renter | At rental end | +| `post_rental_owner` | Owner | 24 hours after rental end | ## Local Development @@ -22,11 +22,6 @@ cd ../conditionCheckReminder && npm install ### Set Up Environment -```bash -cp .env.example .env.dev -# Edit .env.dev with your DATABASE_URL -``` - ### Run Locally ```bash @@ -36,18 +31,3 @@ npm run local # Specify rental ID and check type node -r dotenv/config test-local.js dotenv_config_path=.env.dev 123 rental_start_renter ``` - -## Environment Variables - -| Variable | Description | Example | -|----------|-------------|---------| -| `DATABASE_URL` | PostgreSQL connection string | `postgresql://user:pass@localhost:5432/rentall` | -| `FRONTEND_URL` | Frontend URL for email links | `http://localhost:3000` | -| `SES_FROM_EMAIL` | Sender email address | `noreply@villageshare.app` | -| `EMAIL_ENABLED` | Enable/disable email sending | `false` | -| `SCHEDULE_GROUP_NAME` | EventBridge schedule group | `condition-check-reminders-dev` | -| `AWS_REGION` | AWS region | `us-east-1` | - -## Deployment - -See [infrastructure/cdk/README.md](../../infrastructure/cdk/README.md) for deployment instructions. diff --git a/lambdas/conditionCheckReminder/test-local.js b/lambdas/conditionCheckReminder/test-local.js index b7db0d6..e36c338 100644 --- a/lambdas/conditionCheckReminder/test-local.js +++ b/lambdas/conditionCheckReminder/test-local.js @@ -1,41 +1,29 @@ /** * Local test script for the condition check reminder lambda - * - * Usage: - * 1. Set environment variables (or create a .env file) - * 2. Run: node test-local.js - * - * Required environment variables: - * - DATABASE_URL: PostgreSQL connection string - * - FRONTEND_URL: Frontend URL for email links - * - SES_FROM_EMAIL: Email sender address - * - EMAIL_ENABLED: Set to 'false' to skip actual email sending - * - SCHEDULE_GROUP_NAME: EventBridge schedule group name - * - AWS_REGION: AWS region */ -const { handler } = require('./index'); +const { handler } = require("./index"); // Test event - modify these values as needed const testEvent = { - rentalId: parseInt(process.argv[2]) || 1, // Pass rental ID as CLI arg or default to 1 - checkType: process.argv[3] || 'pre_rental_owner' // Options: pre_rental_owner, rental_start_renter, rental_end_renter, post_rental_owner + rentalId: parseInt(process.argv[2]) || 1, // Pass rental ID as CLI arg or default to 1 + checkType: process.argv[3] || "pre_rental_owner", // Options: pre_rental_owner, rental_start_renter, rental_end_renter, post_rental_owner }; -console.log('Running condition check reminder lambda locally...'); -console.log('Event:', JSON.stringify(testEvent, null, 2)); -console.log('---'); +console.log("Running condition check reminder lambda locally..."); +console.log("Event:", JSON.stringify(testEvent, null, 2)); +console.log("---"); handler(testEvent) - .then(result => { - console.log('---'); - console.log('Success!'); - console.log('Result:', JSON.stringify(result, null, 2)); + .then((result) => { + console.log("---"); + console.log("Success!"); + console.log("Result:", JSON.stringify(result, null, 2)); process.exit(0); }) - .catch(err => { - console.error('---'); - console.error('Error:', err.message); + .catch((err) => { + console.error("---"); + console.error("Error:", err.message); console.error(err.stack); process.exit(1); }); diff --git a/lambdas/imageProcessor/README.md b/lambdas/imageProcessor/README.md index 5121849..42abf21 100644 --- a/lambdas/imageProcessor/README.md +++ b/lambdas/imageProcessor/README.md @@ -20,17 +20,6 @@ cd lambdas/shared && npm install cd ../imageProcessor && npm install ``` -### Set Up Environment - -## Environment Variables - -| Variable | Description | Example | -| -------------- | ---------------------------- | ----------------------------------------------- | -| `DATABASE_URL` | PostgreSQL connection string | `postgresql://user:pass@localhost:5432/db-name` | -| `S3_BUCKET` | S3 bucket name | `bucket-name` | -| `AWS_REGION` | AWS region | `us-east-1` | -| `LOG_LEVEL` | Logging level | `debug`, `info`, `warn`, `error` | - ### Run Locally ```bash diff --git a/lambdas/payoutRetryProcessor/README.md b/lambdas/payoutRetryProcessor/README.md index 82f93fe..ce1e9a0 100644 --- a/lambdas/payoutRetryProcessor/README.md +++ b/lambdas/payoutRetryProcessor/README.md @@ -2,12 +2,6 @@ Retries failed Stripe payouts daily. Triggered by EventBridge Scheduler at 7 AM EST. -## Prerequisites - -- Node.js 20.x -- PostgreSQL database with rentals data -- Stripe account with test API key (`sk_test_...`) - ## Setup 1. Install shared dependencies: @@ -23,17 +17,6 @@ Retries failed Stripe payouts daily. Triggered by EventBridge Scheduler at 7 AM npm install ``` -## Environment Variables - -| Variable | Description | -| ------------------- | ---------------------------------------------- | -| `DATABASE_URL` | PostgreSQL connection string | -| `STRIPE_SECRET_KEY` | Stripe API key (use `sk_test_...` for testing) | -| `FRONTEND_URL` | For email template links | -| `SES_FROM_EMAIL` | Sender email address | -| `SES_FROM_NAME` | Sender display name | -| `EMAIL_ENABLED` | Set to `true` to send emails | - ## Local Testing Run the Lambda locally using your dev environment: @@ -94,7 +77,7 @@ EventBridge Scheduler (7 AM EST daily) v Lambda Function | - +-- Query failed payouts from PostgreSQL + +-- Query failed payouts from database | +-- For each failed payout: | +-- Reset status to "pending" diff --git a/lambdas/shared/db/connection.js b/lambdas/shared/db/connection.js index 2fc4e2d..32cb199 100644 --- a/lambdas/shared/db/connection.js +++ b/lambdas/shared/db/connection.js @@ -7,9 +7,6 @@ let pool = null; * Uses connection pooling optimized for Lambda: * - Reuses connections across invocations (when container is warm) * - Small pool size to avoid exhausting database connections - * - * Expects DATABASE_URL environment variable in format: - * postgresql://user:password@host:port/database */ function getPool() { if (!pool) { @@ -51,22 +48,26 @@ async function query(text, params) { const result = await pool.query(text, params); const duration = Date.now() - start; - console.log(JSON.stringify({ - level: "debug", - message: "Executed query", - query: text.substring(0, 100), - duration, - rows: result.rowCount, - })); + console.log( + JSON.stringify({ + level: "debug", + message: "Executed query", + query: text.substring(0, 100), + duration, + rows: result.rowCount, + }), + ); return result; } catch (error) { - console.error(JSON.stringify({ - level: "error", - message: "Query failed", - query: text.substring(0, 100), - error: error.message, - })); + console.error( + JSON.stringify({ + level: "error", + message: "Query failed", + query: text.substring(0, 100), + error: error.message, + }), + ); throw error; } }