Skip to content

feat(api): LocalStack S3 testing, path-style storage, dist boot + JWT TTL fixes - #55

Merged
xirothedev merged 2 commits into
mainfrom
feat/localstack-storage-testing
Sep 4, 2026
Merged

xirothedev merged 2 commits into
mainfrom
feat/localstack-storage-testing

Conversation

@xirothedev

Copy link
Copy Markdown
Owner

What

Test the self-hosted LocalStack (AWS simulator) against apps/api and fix what it surfaced.

LocalStack storage (6e8b526)

  • R2_FORCE_PATH_STYLE env → forcePathStyle on the S3 client — required because every client defaults to virtual-host addressing, which DNS-fails against LocalStack (R2 unaffected, default stays false)
  • Seed script: create webdevstudios-storage (was webdevstudios, matching no app config); dropped SQS/SNS/DynamoDB/SecretsManager seeds — nothing in any app consumes them; compose scoped to SERVICES=s3
  • bun run smoke:localstack — boots the real StorageService (put → get → delete) against LocalStack
  • CONTEXT.md: added Media store glossary term (S3-compatible object store; R2 = Prod deployment, LocalStack = dev stand-in)

Bugs found by the HTTP boot smoke (4e6478e)

  1. bun run start crashed on main (Nest can't resolve CartService deps): tsc keeps @/* specifiers in emitted JS; bun resolved them from src/ via the dev tsconfig while Nest registered providers from dist/ — two class identities, DI explosion. The Dockerfile already worked around this with a runtime tsconfig; local scripts never got the fix. Now build writes dist/tsconfig.json (aliases resolve into dist, same mechanism as the image), start = build + bun dist/main.js, dev/start:debug = bun --watch src/main.ts. (tsc-alias was evaluated and rejected: it mangles the @prisma/client mapping.)
  2. Access tokens expired in ~3 seconds: jsonwebtoken parses bare numeric strings as milliseconds, so JWT_ACCESS_TOKEN_EXPIRES_IN=3600 meant 3.6s. Numeric config now means seconds; 5m/7d-style values pass through unchanged. Regression spec added.

Verified end-to-end

bun run start (compiled dist) → csrf → login → PATCH /v1/users/avatar (PNG → sharp → WebP) → object visible via awslocal s3 ls on LocalStack → persisted public URL fetches 200. Token TTL now 3600s. Pre-commit hook: api 215 / axum 45 / elysia 39 / effect 39 / infra 9 tests green.

Local repro

  • LocalStack on 127.0.0.1:4566 (any creds), bucket webdevstudios-storage
  • apps/api/.env: R2_ENDPOINT=http://127.0.0.1:4566, R2_FORCE_PATH_STYLE=true, dummy R2_* keys
  • No Postgres/Redis needed for smoke:localstack

@xirothedev
xirothedev merged commit 0c83e42 into main Sep 4, 2026
5 checks passed
@xirothedev
xirothedev deleted the feat/localstack-storage-testing branch September 4, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant