Jgamer1yJ
Deno3y ago
17 replies
Jgamer1y

Is there a recommended library to do dependency injection in Deno?

I'm creating a Rest API with the repository and controllers pattern but my code in the main.ts file keeps getting bigger and bigger

// Repositories
const animeFavoritesRepo = new MongoAnimeFavoritesRepository(mongoDatabase);
const animesRepo = new MongoAnimesRepository(mongoDatabase);
const usersRepo = new MongoUsersRepository(mongoDatabase);
// .... more repos

// Routes
// I'm injectin the controllers and repos
const auth = new AuthRoutes(new AuthController(usersRepo), usersRepo).router();
app.use(auth.routes());
app.use(auth.allowedMethods());
// ... more routes
Was this page helpful?