Jgamer1y
Jgamer1y
DDeno
Created by Jgamer1y on 12/26/2023 in #help
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
// 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
18 replies