Skip to content

chore(portal): remove unused components and files; update TypeScript …#4

Merged
itzTedx merged 1 commit intomainfrom
chore/api-setup
Mar 11, 2026
Merged

chore(portal): remove unused components and files; update TypeScript …#4
itzTedx merged 1 commit intomainfrom
chore/api-setup

Conversation

@itzTedx
Copy link
Copy Markdown
Owner

@itzTedx itzTedx commented Mar 11, 2026

…configuration for improved path resolution

Summary by CodeRabbit

  • New Features

    • API now returns standardized error responses with clear user messaging
    • User authentication and session-based access control implemented
    • New endpoint for creating and managing cards with persistent storage
  • Chores

    • Portal application framework initialized with configuration files
    • Development dependencies reorganized for better maintainability

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 412ab60a-5d0c-4400-b51a-26d32f253d26

📥 Commits

Reviewing files that changed from the base of the PR and between d6995c5 and 03f6762.

⛔ Files ignored due to path filters (7)
  • apps/portal/public/file.svg is excluded by !**/*.svg
  • apps/portal/public/globe.svg is excluded by !**/*.svg
  • apps/portal/public/next.svg is excluded by !**/*.svg
  • apps/portal/public/vercel.svg is excluded by !**/*.svg
  • apps/portal/public/window.svg is excluded by !**/*.svg
  • apps/portal/src/app/favicon.ico is excluded by !**/*.ico
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (29)
  • .cursor/plans/05-email.plan.md
  • .cursor/plans/06-api.plan.md
  • .cursor/plans/08-image-editor-better-upload.plan.md
  • .cursor/plans/10-analytics.plan.md
  • apps/portal/.gitignore
  • apps/portal/README.md
  • apps/portal/lib/.gitkeep
  • apps/portal/next-env.d.ts
  • apps/portal/src/app/layout.tsx
  • apps/portal/src/app/page.tsx
  • apps/portal/src/components/.gitkeep
  • apps/portal/src/components/theme-provider.tsx
  • apps/portal/src/lib/.gitkeep
  • apps/portal/src/lib/auth/client.ts
  • apps/portal/tsconfig.json
  • packages/api/package.json
  • packages/api/src/base.ts
  • packages/api/src/context.ts
  • packages/api/src/index.ts
  • packages/api/src/middleware/auth.ts
  • packages/api/src/middleware/db.ts
  • packages/api/src/middleware/index.ts
  • packages/api/src/middleware/org.ts
  • packages/api/src/middleware/require-auth.ts
  • packages/api/src/routers/card.ts
  • packages/api/src/routers/index.ts
  • packages/db/package.json
  • packages/db/src/schema/card.ts
  • packages/db/src/schema/index.ts

📝 Walkthrough

Walkthrough

This PR establishes foundational API infrastructure for a Next.js project by introducing standardized error handling, authentication and database middleware, schema definitions, and initial route handlers. It also configures the portal application setup files and updates project planning documents with progress tracking.

Changes

Cohort / File(s) Summary
Planning Documents
.cursor/plans/05-email.plan.md, 06-api.plan.md, 08-image-editor-better-upload.plan.md, 10-analytics.plan.md
Reformatted plan structure, added status: pending metadata to todo items, updated table headers in Key Files sections. Scope revised in 06-api.plan.md to defer short-links, reviews, and analytics routers.
Portal Configuration
apps/portal/.gitignore, README.md, next-env.d.ts, src/app/layout.tsx, tsconfig.json
Added standard gitignore rules and comprehensive README with dev/deployment instructions. Updated route type import path and added metadata export to root layout. Changed path alias @/* to resolve to ./src/*.
API Base Infrastructure
packages/api/src/base.ts, context.ts, index.ts, package.json
Established centralized error handling via ORPCContext interface with predefined HTTP error codes (UNAUTHORIZED, FORBIDDEN, NOT_FOUND, BAD_REQUEST, CONFLICT, etc.). Exported createContext function and new procedures publicProcedure and protectedProcedure. Reorganized dependencies in package.json.
API Middleware Layer
packages/api/src/middleware/auth.ts, db.ts, org.ts, require-auth.ts, index.ts
Implemented session validation (authMiddleware), database injection (dbProvider), organization slug verification (orgMiddleware), and header-based session retrieval (requireAuth). All middleware validates state and propagates context downstream.
API Routers
packages/api/src/routers/card.ts, index.ts
Created createCard POST route with DB integration, output schema validation, and HTTP metadata. Aggregated routes in router module with type exports Router and RouterClient.
Database Schema
packages/db/src/schema/card.ts, schema/index.ts, package.json
Defined PostgreSQL cards table with id primary key, name field, and timestamp columns using drizzle-orm. Exported schema via barrel file and added ./schema to package exports.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Middleware as Middleware Chain
    participant Auth as Auth Handler
    participant DB as DB Context
    participant Router as Router/Handler
    
    Client->>Middleware: HTTP Request
    Middleware->>Auth: requireAuth/authMiddleware
    Auth->>Auth: Validate session via headers
    alt Session invalid
        Auth-->>Client: UNAUTHORIZED Error (401)
    else Session valid
        Auth->>Middleware: Context {session, user}
        Middleware->>Middleware: orgMiddleware (check x-org-slug)
        alt Org slug missing or not found
            Middleware-->>Client: BAD_REQUEST/FORBIDDEN Error
        else Org valid
            Middleware->>DB: dbProvider inject database
            DB->>Middleware: Context {db}
            Middleware->>Router: publicProcedure with all context
            Router->>Router: Execute handler (e.g., createCard)
            Router->>DB: Insert into cards table
            DB-->>Router: Card created
            Router-->>Client: Response {cardName}
        end
    end
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

Poem

🐰✨ A rabbit hops through the API forest,
Middleware pipelines stand pristine and gorgeous!
Error codes sorted, contexts flow bright,
From auth to db, everything's tight.
Infrastructure blooming, the foundation's set right! 🌿

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/api-setup

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.

@itzTedx itzTedx merged commit 60c2248 into main Mar 11, 2026
1 of 3 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 11, 2026
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