Skip to content

Add Multi-Database Support #12

@ashbhati26

Description

@ashbhati26

Add Multi-Database Support

Problem Description

authpool is tightly coupled with MongoDB and Mongoose. Developers using other databases (e.g., PostgreSQL with Prisma, MySQL with Sequelize) cannot use this package without rewriting significant parts.

Proposed Solution

  • Abstract database logic via an adapter pattern.
  • Allow injecting a userAdapter in config:
startAuthServer({
  userAdapter: {
    findOrCreateUser: async (googleProfile) => {...},
    findUserById: async (id) => {...},
  }
});

Keep MongoDB as the default but fallback to adapter if provided.

Why this matter

Multi-database support makes authpool a framework-agnostic, future-proof solution. It can then serve any stack, from MERN to PostgreSQL-based backends.

Acceptance Criteria

  • Supports a custom userAdapter object with required methods.
  • MongoDB fallback works as default if adapter is not passed.
  • Proper validation and error-handling if adapter is misconfigured.
  • Examples included in README (e.g., Prisma + PostgreSQL usage).

Metadata

Metadata

Assignees

No one assigned

    Labels

    db-supportWork on dynamic or multi‑database user models

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions