Skip to content

No --multitenant flag on grit new to scaffold orgs + scoped middleware #62

@MUKE-coder

Description

@MUKE-coder

Multi-tenancy is the foundation of every B2B-ish app, but grit new doesn't have it. Adding it after the scaffold is painful — you have to retrofit Org + Membership tables, sprinkle orgId scoping through every handler, add an org switcher to the frontend, write the invite flow, etc.

Across 18 starter-kit build plans I'm shipping, 6 of the Grit-based ones need this from day one: CRM, Agent Control, ERP, High-Scale Marketplace, IoT Console, LMS-style multi-instructor.

Proposed fix:
New grit new ... --multitenant flag that:

  • Generates Organisation + Membership + Invitation models with Casbin role policies (Owner / Admin / Member / Viewer)
  • Adds a RequireOrgMembership middleware that scopes every protected handler to the org in the URL prefix (/o/:slug/...)
  • Scaffolds org switcher + invite flow on the frontend (works with both --next and --vite)
  • Updates grit generate resource to ALWAYS include an orgId foreign key when multi-tenancy is on

Saves every B2B-ish Grit user a week of setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions