Skip to content

Backend - Multi-Tenant Onboarding Transactional API #74

@inteee

Description

@inteee

Context: Creating a new clinic involves creating the Clinic record AND the first Admin user. This must happen in a single database transaction to prevent orphaned data.
Location: apps/api/src/modules/clinics/onboarding.controller.ts
Requirements:

  1. Create POST /clinics/register.
  2. Accept payload: Clinic Name, Admin Email, Admin Password.
  3. Use a Mongoose Transaction (Session) to insert the Clinic, retrieve its _id, and insert the User with role CLINIC_ADMIN tied to that clinicId.
    Acceptance Criteria:
  • If user creation fails, the clinic creation rolls back (database transaction works).
  • Registration returns a valid JWT to auto-login the new admin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions