findings
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v45View latest version
Webhook handlers for Notion integrations.
POST /tasks/blob
- Process PDF extraction and blob storage for Notion pagesPOST /tasks/dupe
- Duplicate Notion page to final reports database with content filteringPOST /tasks/convert
- Convert page to database based on H2 sectionsPOST /tasks/draft
- Duplicate page with filtered child database (excludes specific analysis properties)POST /tasks/notion-webhook
- General Notion webhook handlerPOST /tasks/test
- Test endpoint for webhook authenticationGET /tasks/debug-webhook
- Debug endpoint to check webhook configuration
Routes handle HTTP request/response only. Business logic is delegated to:
tasks.controller.ts
- Orchestrates PDF extraction, blob storage, page duplication, and Notion updatesnotion.service.ts
- Handles Notion API callspdfExtractor.ts
- Handles PDF text extraction
The /tasks/dupe
endpoint duplicates a Notion page from any database to the final reports database (FINDINGS_REPORTS_DRAFT_DB_ID
) with content filtering:
- Removes: Callout blocks, code blocks, divider blocks, blocks containing "Evidence summary", blocks containing "Methodology", blocks containing "Executive summary"
- Preserves: All other content blocks in original order
- Source: Original page remains unchanged
Expects Notion webhook with page ID in data.id
:
{ "data": { "id": "page-id-here" } }
{ "success": true, "sourcePageId": "source-page-id", "targetPageId": "new-page-id", "blocksCopied": 15, "blocksFiltered": 3, "timestamp": "2025-08-15T22:25:47.000Z" }
The /tasks/draft
endpoint duplicates a Notion page and its child database to the draft reports database (FINDINGS_REPORTS_DRAFT_DB_ID
) with selective property filtering:
- Uses "Results Database ID" property from source page to identify child database
- If no child database ID found, proceeds with page duplication only
Excluded from child database:
- Confidence Score
- Consensus Level
- Evidence Summary
- Methodology
Preserved in child database:
- Name (title)
- Status
- Category
- Priority
- All other properties
- Page Content: Copies all blocks except child_database blocks
- Child Database: Creates new filtered database with all pages duplicated
- Name Property: Replaces "(raw)" with "(draft)" or appends "(draft)"
{ "success": true, "sourcePageId": "source-page-id", "targetPageId": "new-page-id", "childDatabaseId": "source-child-db-id", "targetChildDatabaseId": "new-child-db-id", "childPagesProcessed": 25, "childPagesSucceeded": 25, "timestamp": "2025-08-15T22:25:47.000Z" }