Skip to content

feat: implement GET /bounties/:id endpoint (closes #21)#34

Open
kenchambers wants to merge 1 commit intodevasignhq:mainfrom
kenchambers:feat/get-bounties-id
Open

feat: implement GET /bounties/:id endpoint (closes #21)#34
kenchambers wants to merge 1 commit intodevasignhq:mainfrom
kenchambers:feat/get-bounties-id

Conversation

@kenchambers
Copy link

Summary

Implements GET /bounties/:id as specified in issue #21 — full bounty detail with creator info, application count, assignee info, and current status.

This PR also scaffolds the packages/api package (Hono + Drizzle ORM + Neon PostgreSQL) since it is the foundation all API issues depend on.


What's included

Database schemas (Drizzle)

File Resolves
packages/api/src/db/schema/users.ts Issue #7
packages/api/src/db/schema/bounties.ts Issue #8
packages/api/src/db/schema/applications.ts Issue #9
packages/api/src/db/index.ts Issue #6

API entry point

packages/api/src/index.ts — Hono app with CORS, request logger, error handler, and GET /health (issue #2).

Route: GET /bounties/:id

packages/api/src/routes/bounties.ts

Response shape:

{
  "data": {
    "id": "<uuid>",
    "githubIssueId": 42,
    "repoOwner": "acme",
    "repoName": "frontend",
    "title": "Fix layout bug",
    "description": "...",
    "amountUsdc": "500.000000",
    "techTags": ["React", "CSS"],
    "difficulty": "intermediate",
    "status": "open",
    "deadline": "2026-03-01T00:00:00.000Z",
    "applicationCount": 3,
    "creator": { "id": "...", "username": "alice", "avatarUrl": "https://..." },
    "assignee": null,
    "createdAt": "2026-02-01T00:00:00.000Z",
    "updatedAt": "2026-02-10T00:00:00.000Z"
  }
}

Error responses:

  • 400 — id is not a valid UUID (db is never queried)
  • 404 — bounty not found

Tests

5 Vitest unit tests — all green:

✓ 200 open unassigned bounty — full payload
✓ 200 assigned bounty — assignee object populated
✓ 404 bounty not found
✓ 400 invalid UUID — db never called
✓ all required response fields present

Run them locally:

cd packages/api
npm install
npm test

Verification steps

  1. cd packages/api && npm test — all 5 pass
  2. Set DATABASE_URL in packages/api/.env (see .env.example)
  3. Run migrations: npm run db:generate && npm run db:migrate
  4. npm run dev and hit GET /bounties/<valid-uuid>
  5. Confirm 200 with full detail; confirm 404 for unknown id; confirm 400 for malformed id

Scaffolds the packages/api directory with Hono + Drizzle ORM and implements
the GET /bounties/:id route with full bounty detail response.

What's included
───────────────
packages/api/src/db/schema/
  users.ts        — users table (issue devasignhq#7)
  bounties.ts     — bounties table with difficulty + status enums (issue devasignhq#8)
  applications.ts — applications table w/ unique(bounty_id, applicant_id) (issue devasignhq#9)
  index.ts        — barrel re-export

packages/api/src/db/index.ts
  Neon serverless driver + Drizzle connection (issue devasignhq#6)

packages/api/src/index.ts
  Hono app with CORS, logger, error handler, health check (issue devasignhq#2)

packages/api/src/routes/bounties.ts
  GET /bounties/:id handler — resolves issue devasignhq#21
  • UUID format validated before touching the database (400 on bad format)
  • INNER JOIN to users for creator (id, username, avatarUrl)
  • LEFT JOIN to users for assignee (null when unassigned)
  • Separate count() query for applicationCount
  • 404 with structured error when bounty not found

packages/api/src/types/bounty.types.ts
  BountyDetailResponse, BountyDetailApiResponse

packages/api/src/lib/errors.ts
  notFound(), badRequest(), internalError() helpers

packages/api/tests/bounties.test.ts
  5 Vitest tests — all passing:
  ✓ 200 open unassigned bounty — full payload
  ✓ 200 assigned bounty — assignee object populated
  ✓ 404 bounty not found
  ✓ 400 invalid UUID — db never called
  ✓ all required response fields present

Run tests: cd packages/api && npm test
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.

2 participants