Skip to content

Postgres connection pooling, automated startup migrations, cached gig search, IPFS API integration tests - #197

Merged
meshackyaro merged 1 commit into
trustflow-protocol:mainfrom
kris-nana:feat/postgres-conn-migrations-gig-cache-ipfs-tests
Aug 27, 2026
Merged

Postgres connection pooling, automated startup migrations, cached gig search, IPFS API integration tests#197
meshackyaro merged 1 commit into
trustflow-protocol:mainfrom
kris-nana:feat/postgres-conn-migrations-gig-cache-ipfs-tests

Conversation

@kris-nana

Copy link
Copy Markdown
Contributor

Summary

Closes #27, Closes #40, Closes #41, Closes #47

  • Configure PostgreSQL connection #27 — Configure PostgreSQL connection: adds DatabaseModule/DatabaseService (backend/src/common/database) providing a pg connection pool configured via DATABASE_URL or discrete DB_HOST/DB_PORT/DB_NAME/DB_USER/DB_PASSWORD env vars, with pool-size/timeout/SSL tuning. Mirrors the existing RedisModule pattern: resolves to null when unconfigured so the app still boots without a local Postgres. Wired into AppModule and into GET /health, which now reports a database check.
  • Add automated DB Migrations #47 — Add automated DB migrations: adds MigrationStartupService, which runs every migration registered with MigrationRegistryService automatically on boot via OnApplicationBootstrap, instead of requiring a manual POST /migrations/:name/run per migration. Gated by RUN_MIGRATIONS_ON_STARTUP (defaults to enabled outside NODE_ENV=test); one migration failing doesn't block the others or app startup.
  • Implement caching for Gig search #40 — Implement caching for gig search: adds GET /gigs, a paginated search endpoint over gig solicitations (status/page/limit, defaulting to open gigs sorted newest first). Results are cached in Redis for GIG_SEARCH_CACHE_TTL_SECONDS (default 30s); every gig mutation invalidates the cache via a tracked key set so a stale page is never served.
  • Draft API integration tests for IPFS pinning #41 — Draft API integration tests for IPFS pinning: adds a Supertest-driven API integration suite (ipfs-pinning.e2e-spec.ts) that boots a real Nest application and exercises the full HTTP surface of the pinning API — auth, pin/list/get/verify/unpin, provider failover, full-failure 503, and automatic re-pin recovery — against fake providers injected via the PIN_PROVIDERS DI token, so no external network calls are made.

All new env vars are documented in .env.example and backend/SETUP_INSTRUCTIONS.md.

Test plan

  • npm run lint:check — clean (only pre-existing warnings in untouched files)
  • npx tsc --noEmit — clean
  • npm run build — clean
  • npx jest — all tests pass except a pre-existing, unrelated flaky test (common/idempotency/idempotency.integration.spec.ts, a concurrency race test not touched by this PR)

…cached gig search, and IPFS API integration tests

Configure PostgreSQL connection (trustflow-protocol#27)
- New DatabaseModule/DatabaseService (src/common/database) providing a pg
  Pool configured via DATABASE_URL or discrete DB_HOST/DB_PORT/DB_NAME/
  DB_USER/DB_PASSWORD, with pool-size/timeout/SSL env vars. Mirrors
  RedisModule: resolves to null when unconfigured so the app still boots
  without a local Postgres.
- Wired into AppModule and into GET /health, which now reports a
  `database` check (true/not-applicable when unconfigured, real ping
  result once DATABASE_URL or DB_HOST/DB_NAME is set).

Add automated DB migrations (trustflow-protocol#47)
- New MigrationStartupService runs every migration registered with
  MigrationRegistryService automatically via OnApplicationBootstrap,
  instead of requiring a manual POST /migrations/:name/run per migration.
  Gated by RUN_MIGRATIONS_ON_STARTUP (defaults to enabled outside
  NODE_ENV=test); a failure in one migration is logged and doesn't block
  the others or app startup.

Implement caching for gig search (trustflow-protocol#40)
- New GET /gigs endpoint: paginated search over gig solicitations
  (status/page/limit query params, defaulting to open gigs sorted newest
  first).
- Results are cached in Redis for GIG_SEARCH_CACHE_TTL_SECONDS (default
  30s) to reduce load on repeated queries; every gig mutation
  (create/accept/cancel/update/remove/expire) invalidates the cache via a
  tracked key set, so a change is never masked by a stale cached page.

Draft API integration tests for IPFS pinning (trustflow-protocol#41)
- New Supertest-driven API integration suite
  (ipfs-pinning.e2e-spec.ts) that boots a real Nest application and
  exercises the full HTTP surface of the pinning API — auth, pin/list/
  get/verify/unpin, provider failover, full-failure 503, and automatic
  re-pin on a silently dropped provider — against fake providers injected
  via the PIN_PROVIDERS token, so no external network calls are made.

Co-Authored-By: KRIS <307999362+kris-nana@users.noreply.github.com>
@kris-nana
kris-nana requested a review from meshackyaro as a code owner August 27, 2026 16:57
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@kris-nana Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@meshackyaro
meshackyaro merged commit 9350251 into trustflow-protocol:main Aug 27, 2026
1 check passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Aug 27, 2026
10 tasks
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.

Add automated DB Migrations Draft API integration tests for IPFS pinning Implement caching for Gig search Configure PostgreSQL connection

2 participants