Skip to content

Unify router API #6

@Yeseh

Description

@Yeseh

Currently, users need to use two separate classes to instantiate routers for different database types. The API could be more made more unified and straightforward by creating a single entry point.

For example:

import {induct} from "@inductjs/core";

// Instantiate with new factory function
const inductRouter = induct({
     db: knex,  // auto detect mongo or knex connection object to return correct Induct class
     schema: UserSchema,
     tableName: "dbo.users", // make tableName required for sql instances
     idField: "uuid",  //  extend possible id fields with "_id" for mongo instances
})

const router = inductRouter.default()  // returns express router with default routes

// add other 
router.get("/extra", someOtherHandler)

export default router;

Metadata

Metadata

Assignees

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