Skip to content

Test#105

Merged
sweetmantech merged 7 commits intomainfrom
test
Jan 9, 2026
Merged

Test#105
sweetmantech merged 7 commits intomainfrom
test

Conversation

@sweetmantech
Copy link
Contributor

@sweetmantech sweetmantech commented Jan 9, 2026

Summary by CodeRabbit

  • New Features

    • New API endpoint for creating chats with API key authentication and cross-origin request support
  • Changes

    • room_id field is now required for email operations

✏️ Tip: You can customize this high-level summary in your review settings.

sweetmantech and others added 7 commits January 8, 2026 10:56
The room_id parameter is now required to ensure all outbound emails
include the chat link footer, enabling email thread continuity.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…-email-tool-room_id-required

feat: make room_id required in send_email tool
- Add createChatHandler in lib/chats/
- Add POST route at app/api/chats/
- Account ID inferred from API key
- Optional artistId and chatId params
- chatId auto-generated if not provided

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Document validate function pattern using Zod in CLAUDE.md
- Add validateCreateChatBody.ts for POST /api/chats
- Update createChatHandler to use the validate function

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create safeParseJson helper that returns {} if body is empty/invalid
- Use in createChatHandler so body is not required
- All params are optional, so empty body should work

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…-rooms-post-chats

Add POST /api/chats endpoint
@vercel
Copy link
Contributor

vercel bot commented Jan 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
recoup-api Ready Ready Preview Jan 9, 2026 3:08pm

@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

These changes introduce chat creation functionality by adding a new API route handler, request body validation using Zod, and JSON parsing utilities. The implementation includes API key authentication, request validation with structured error responses, database insertion, and CORS support.

Changes

Cohort / File(s) Summary
Documentation
CLAUDE.md
Guidance section for input validation patterns using Zod, including schema definition, return types, error handling conventions, and file naming standards.
Chat API Route
app/api/chats/route.ts
New route handler with OPTIONS (CORS headers) and POST (delegates to createChatHandler) methods.
Chat Creation Logic
lib/chats/createChatHandler.ts, lib/chats/validateCreateChatBody.ts
Handler for creating chat rooms with API key authentication, body validation, and database insertion. Includes Zod schema with optional artistId and chatId fields, validation function returning 400 on errors, and 200 on success.
Networking Utilities
lib/networking/safeParseJson.ts
Utility function for safely parsing JSON from NextRequest with fallback to empty object on errors.
Schema Updates
lib/emails/sendEmailSchema.ts
Changed room_id field from optional to required in sendEmailSchema.

Sequence Diagram

sequenceDiagram
    participant Client
    participant RouteHandler as Route Handler
    participant Auth as Auth Service
    participant Validator as Validator
    participant Parser as JSON Parser
    participant Database as Database
    participant CORS as CORS Helper

    Client->>RouteHandler: POST /api/chats
    RouteHandler->>Auth: getApiKeyAccountId(request)
    Auth-->>RouteHandler: accountId or error
    alt Auth Error
        RouteHandler->>CORS: getCorsHeaders()
        RouteHandler-->>Client: 401 Response
    else Auth Success
        RouteHandler->>Parser: safeParseJson(request)
        Parser-->>RouteHandler: parsed body
        RouteHandler->>Validator: validateCreateChatBody(body)
        alt Validation Error
            Validator->>CORS: getCorsHeaders()
            Validator-->>RouteHandler: 400 NextResponse
            RouteHandler-->>Client: 400 Response
        else Validation Success
            Validator-->>RouteHandler: CreateChatBody
            RouteHandler->>Database: insertRoom(chatData)
            Database-->>RouteHandler: chat object
            RouteHandler->>CORS: getCorsHeaders()
            RouteHandler-->>Client: 200 {status: "success", chat}
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hops of joy through validation gates,
Chat rooms spring where auth awaits,
Safe JSON flows, schemas aligned,
CORS headers wrap, no errors left behind!
A feature complete, from route to database call,
The rabbit approves—this code has it all! 🎉

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b90ec3a and dbee139.

📒 Files selected for processing (6)
  • CLAUDE.md
  • app/api/chats/route.ts
  • lib/chats/createChatHandler.ts
  • lib/chats/validateCreateChatBody.ts
  • lib/emails/sendEmailSchema.ts
  • lib/networking/safeParseJson.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Comments