Commit Graph
43 Commits
Author SHA1 Message Date
asepharyana 06f93e30f6 feat: proxy GetObject from Telegram CDN for real S3 client compatibility
- Add proxyS3Get config (PROXY_S3_GET env, default true) to env.ts
- Proxy handleGetObject and handleGetMultipartObject: fetch from Telegram
  CDN and return 200 with streaming body instead of 302 redirect
- Real S3 clients (AWS SDK v3) expect 200+body on GetObject, not redirect
- Legacy 302 redirect path preserved when proxyS3Get=false
- Updated production-e2e: GetObject asserts 200 with body content
- Updated s3-sdk.test.ts: GetObject asserts 200 with body (removed try/catch)
- Cleaned up unused multipart imports in s3-sdk.test.ts

All 49 tests pass (29 production-e2e + 20 s3-sdk).
2026-07-07 02:54:51 +07:00
asepharyana f88ac1a124 test: add real AWS SDK v3 S3 compatibility tests (20 tests)
Tests use @aws-sdk/client-s3 against https://upload.asepharyana.my.id
with forcePathStyle=true. Covers all standard S3 operations:
ListBuckets, CreateBucket, HeadBucket, DeleteBucket, PutObject,
GetObject, HeadObject, ListObjectsV1/V2 (prefix, delimiter),
CopyObject, DeleteObject, DeleteObjects (batch), error handling.

Multipart is excluded from SDK tests — the SDK adds amz-sdk-* /
x-amz-user-agent to signed headers, which can differ between
signing time and the actual request through Cloudflare, causing
403 SignatureDoesNotMatch. Multipart is verified via manual
SigV4 signing in test/production-e2e.test.ts.
2026-07-07 01:59:17 +07:00
asepharyana 57f2740df9 fix: production bugs + comprehensive production e2e tests
Fixes:
- RowList bug: postgres.js returns array directly, not {rows}. Fix in
  buckets.ts, files-ext.ts, multipart.ts (3 files, 8 functions)
- S3 ListBuckets routing: GET / was intercepted by handleHome route
- Presigned URL detection: isS3Request() only checked Authorization header
- FK constraint on bucket delete: cascade-delete files & multipart rows first
- docker-compose.yml: pass S3_ACCESS_KEY / S3_SECRET_KEY to container
- Dockerfile: copy home.html to runner stage for handleHome

Tests:
- test/production-e2e.test.ts: 29 tests (11 Web API + 18 S3 SigV4)
  All pass against https://upload.asepharyana.my.id
- Creates and cleans up real buckets/objects on production
2026-07-07 00:49:45 +07:00
asepharyana 245138e23a Refactor code for improved readability and consistency
- Updated formatting in web-api.ts for better alignment and readability.
- Enhanced XML builders in xml.ts for clearer structure and maintainability.
- Improved test cases in s3-auth.test.ts and s3-operations.test.ts for better clarity and consistency.
- Refactored mock data in web-api.test.ts for improved readability.
2026-07-06 22:36:15 +07:00
asepharyana e175a27512 test: add S3 auth, operations, and web API tests 2026-07-06 21:15:26 +07:00
asepharyana 52bd704d21 refactor: enhance file handling and metrics tracking; remove unused bot health tracker 2026-07-06 01:25:18 +07:00
MythEclipseandClaude Opus 4.8 50176e5764 chore: migrate domain asepharyana.tech to asepharyana.my.id
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 12:39:26 +07:00
MythEclipse 2a833d3908 feat: include bot token in file info response for Telegram API 2026-05-30 00:15:35 +07:00
MythEclipse 8508b36026 feat: update file handling to redirect to Telegram CDN and adjust Swagger documentation 2026-05-29 03:43:49 +07:00
MythEclipse 5425f6d33d feat: enhance configuration and rate limiting
- Added new configuration options: trustProxy, uploadConcurrency, batchMaxItems, batchMaxSizeBytes, and maxRequestBodyBytes to AppConfig.
- Implemented utility functions for parsing environment variables and masking sensitive data.
- Updated rate limiting logic to use configurable window size and maximum requests per window.
- Introduced a middleware for rate limiting on specific routes.
- Refactored file handling routes to support streaming downloads instead of redirects.
- Improved error handling and response formatting in file routes.
- Added support for oversized request rejection based on Content-Length header.
- Updated Swagger documentation to reflect changes in API behavior and responses.
- Enhanced tests to cover new features and ensure proper functionality.
2026-05-29 03:33:39 +07:00
MythEclipse db5de1367d feat: extend file schema with archive metadata, implement batch upload processing, and add zip utilities for file handling 2026-05-22 00:51:49 +07:00
MythEclipse 10c968cf01 feat: add file_hash column and related index to files table; refactor Telegram API utilities for improved file handling 2026-05-21 22:55:42 +07:00
MythEclipse 52340ee77d feat: enhance file upload handling with improved file detection, size limits, and response formatting 2026-05-21 22:31:55 +07:00
MythEclipse 884710fd42 feat: implement temporary file handling for uploads and update tests for dynamic ID verification 2026-05-18 22:01:26 +07:00
MythEclipse d58b2390ef refactor: remove concurrency limit from Telegram upload queue and enhance media group handling 2026-05-18 21:54:39 +07:00
MythEclipse 0bc12651db fix: clean up logger info message formatting and remove unused import in rate limit tests 2026-05-18 21:19:38 +07:00
MythEclipse 825e969569 feat: implement multi-bot support for Telegram API with rate limit handling and add task queue for uploads 2026-05-18 21:18:16 +07:00
MythEclipse 721fa3db7d feat: implement auto-retry for Telegram API requests on error 429 and update documentation 2026-05-18 21:02:38 +07:00
MythEclipseandClaude Opus 4.7 91cfee0b37 fix: load BOT_TOKEN from process.env in tests to prevent leaks
- Update test/bot.test.ts to use process.env.BOT_TOKEN || 'fallback'
- Update docs/superpowers/plans/2026-05-18-deploy-plan.md to use placeholders
- Completely eliminates hardcoded active API token from codebase

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 19:55:03 +07:00
MythEclipseandClaude Opus 4.7 525348b1f3 fix: make forwardToStorage fully dynamic based on fileType
- Replace forceDocument boolean with fileType string in forwardToStorage
- Dynamically call matching sendPhoto, sendAudio, sendVideo, sendVoice, sendAnimation, sendSticker, or sendDocument Telegraf API method
- Correctly extract uploaded file details based on what Telegram returned
- Fixes IMAGE_PROCESS_FAILED 500 error when uploading ogg audio, video, sticker, or voice notes via HTTP
- Update upload.ts, bot.ts, and test suites to match the new dynamic signature

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 19:52:46 +07:00
MythEclipse a0262e2d46 style: run formatter on modified files 2026-05-18 19:41:51 +07:00
MythEclipseandClaude Opus 4.7 ea4341fdfe feat: implement deduplication and all media types in bot listener
- Expand registered bot listener to support sticker and video_note media types
- Check database for existing telegramFileUniqueId to bypass forwarding duplicates
- Update tests to assert deduplication and new formats handling in bot.test.ts

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 19:41:16 +07:00
MythEclipseandClaude Opus 4.7 04a2e52250 feat: implement deduplication in HTTP upload router
- Compute SHA-256 hash using computeHash for multipart and JSON uploads
- Query database for existing file records with the same hash
- Return existing metadata and download URL immediately on duplicate match without reforwarding to Telegram
- Include fileHash in newly inserted file database records

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 19:39:55 +07:00
MythEclipseandClaude Opus 4.7 4e805689c1 feat: extend file type classification and implement computeHash
- Add sticker (webp) and video_note to classification mapping and file limits
- Handle unknown mime or caption fallback to document
- Implement computeHash utility using Bun.CryptoHasher for sha256 checksums
- Update and add comprehensive tests in file.test.ts

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 19:38:12 +07:00
MythEclipseandClaude Opus 4.7 22c2133b24 feat: add fileHash column to files schema
Update files database schema and test suite to support fileHash property.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 19:36:19 +07:00
MythEclipse ed7f607ee4 style: sort imports in telegram test to satisfy Biome check 2026-05-18 08:55:22 +07:00
MythEclipse ed88069e60 fix: assert sendDocument with config.storageChatId to match dynamic mock env in CI 2026-05-18 08:54:24 +07:00
MythEclipse c0827b09c5 fix: make DB tests more robust by checking definition rather than strict module identity 2026-05-18 08:42:49 +07:00
MythEclipse 91986d1d51 fix: upload binary files to Telegram with source payload 2026-05-18 08:18:55 +07:00
MythEclipse 6feca3564a feat: add Swagger OpenAPI documentation endpoints 2026-05-18 07:39:27 +07:00
MythEclipse cf79a1f195 style: format and lint codebase using Biome v2 2026-05-18 07:29:01 +07:00
MythEclipse 3f4e697733 feat: migrate entire codebase to TypeScript 2026-05-18 07:27:06 +07:00
MythEclipse 252b2e4a1f test: isolate module mocking and add sequential test script 2026-05-18 07:16:30 +07:00
MythEclipseandClaude Opus 4.7 99b820709d feat: setup HTTP server and bootstrap application
Setup HTTP server with Bun.serve and bootstrap Telegram bot and other services.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 07:14:35 +07:00
MythEclipseandClaude Opus 4.7 4996d7548a feat: add Telegram bot handler
Implement Telegraf bot instance with file upload/forward handlers and mock test verification.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 07:13:17 +07:00
MythEclipseandClaude Opus 4.7 be93a06918 feat: add health check route
Implement handleHealth endpoint for Bun.serve to verify DB connection.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 07:10:55 +07:00
MythEclipseandClaude Opus 4.7 d915814277 feat: add file routes (download redirect & info)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 07:09:29 +07:00
MythEclipseandClaude Opus 4.7 d7b8e9dd08 feat: add upload API handler (multipart & base64)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 07:08:13 +07:00
MythEclipseandClaude Opus 4.7 1e29433d5d feat: add Telegram API utilities
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 07:06:21 +07:00
MythEclipseandClaude Opus 4.7 b621a73ca9 feat: add file validation utilities
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 07:02:14 +07:00
MythEclipseandClaude Opus 4.7 db71f29288 feat: add in-memory rate limiter
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 07:01:32 +07:00
MythEclipseandClaude Opus 4.7 281329a1af feat: add Drizzle ORM database layer
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 07:00:46 +07:00
MythEclipseandClaude Opus 4.7 f9c0bc0768 feat: add environment variables validation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 06:58:55 +07:00