InversifyJS configuration

We are going to declare some type bindings. We are going to declare the type bindings using AsyncContainerModule because we need to wait for the database connection to be ready. We are going to declare a binding for MovieRepository. We don't need to declare a binding for the MovieController because the @controller(path) annotation will create it for us. However, we need to import the controller to ensure that the decorator is executed and, as a result, the binding is declared:

import { AsyncContainerModule } from "inversify"; import { Repository, Connection } from "typeorm"; import { Movie } from "./entities/movie"; import { getDbConnection } from "./db"; import { getRepository } from "./repositories/movie_repository"; ...

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.