text clean up
This commit is contained in:
@@ -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.",
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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",
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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(),
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ 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 |
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
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);
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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({
|
||||
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({
|
||||
console.error(
|
||||
JSON.stringify({
|
||||
level: "error",
|
||||
message: "Query failed",
|
||||
query: text.substring(0, 100),
|
||||
error: error.message,
|
||||
}));
|
||||
}),
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user