Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/backend/lambdas/auth/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export const handler = async (event: any): Promise<APIGatewayProxyResult> => {
// Support both API Gateway and Lambda Function URL events
// API Gateway: event.path, event.httpMethod
// Function URL: event.rawPath, event.requestContext.http.method
const rawPath = event.rawPath || event.path || '/';
const fullPath = event.rawPath || event.path || '/';
// API Gateway mounts this service at /auth[/{proxy+}]; strip the mount
// prefix so routing below (rawPath and normalizedPath) sees the bare path.
const rawPath = fullPath.replace(/^\/auth(?=\/|$)/, '') || '/';
const normalizedPath = rawPath.replace(/\/$/, '');
const method = (event.requestContext?.http?.method || event.httpMethod || 'GET').toUpperCase();

Expand Down
809 changes: 808 additions & 1 deletion apps/backend/lambdas/auth/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions apps/backend/lambdas/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"dev": "ts-node --transpile-only dev-server.ts",
"build": "tsc",
"test": "start-server-and-test dev http-get://localhost:3000/auth/health jest",
"package": "npm run build && cd dist && zip -r ../lambda.zip . -x '*.map' 'dev-server.*' 'swagger-utils.*'"
"package": "esbuild handler.ts --bundle --platform=node --target=node20 --outfile=dist/handler.js && cd dist && zip -q ../lambda.zip handler.js"
},
"devDependencies": {
"@branch/types": "file:../../../../shared/types",
"@jest/globals": "^30.2.0",
"esbuild": "^0.25.12",
"jest": "^30.2.0",
"@types/aws-lambda": "^8.10.131",
"@types/jest": "^30.0.0",
"@types/node": "^20.11.30",
Expand All @@ -26,7 +28,6 @@
"@aws-sdk/client-cognito-identity-provider": "^3.978.0",
"amazon-cognito-identity-js": "^6.3.16",
"dotenv": "^17.2.3",
"jest": "^30.2.0",
"kysely": "^0.28.10",
"pg": "^8.17.2"
}
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/lambdas/donors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Lambda for managing donors.
|--------|------|-------------|
| GET | /health | Health check |
| GET | /donors | |
| POST | /donations | |
| GET | /donations | |
| POST | /donors | |

## Setup
Expand Down
7 changes: 5 additions & 2 deletions apps/backend/lambdas/donors/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export const handler = async (event: any): Promise<APIGatewayProxyResult> => {
// Support both API Gateway and Lambda Function URL events
// API Gateway: event.path, event.httpMethod
// Function URL: event.rawPath, event.requestContext.http.method
const rawPath = event.rawPath || event.path || '/';
const fullPath = event.rawPath || event.path || '/';
// API Gateway mounts this service at /donors[/{proxy+}]; strip the mount
// prefix so routing below (rawPath and normalizedPath) sees the bare path.
const rawPath = fullPath.replace(/^\/donors(?=\/|$)/, '') || '/';
const normalizedPath = rawPath.replace(/\/$/, '');
const method = (event.requestContext?.http?.method || event.httpMethod || 'GET').toUpperCase();

Expand Down Expand Up @@ -133,7 +136,7 @@ export const handler = async (event: any): Promise<APIGatewayProxyResult> => {
}

// POST /donors
if (normalizedPath === '/donors' && method === 'POST') {
if ((normalizedPath === '/' || normalizedPath === '/donors') && method === 'POST') {
const body = event.body ? JSON.parse(event.body) as Record<string, unknown> : {};
// TODO: Add your business logic here
return json(201, { ok: true, route: 'POST /donors', body });
Expand Down
Loading
Loading