Skip to main content

Getting started

Install dependencies

To get started with Inversify HTTP, first install the required packages.

Begin by installing the inversify packages and reflect-metadata:

  npm install inversify reflect-metadata @inversifyjs/http-core
warning

Make sure to enable the Experimental Decorators and Emit Decorator Metadata options in your tsconfig.json.

Choose an HTTP adapter

Inversify HTTP works with several HTTP frameworks. Choose the adapter that best fits your needs:

  npm install @inversifyjs/http-express-v4

Configure server

After installing the packages, create a server to listen for incoming requests. Below is a basic example of setting up an Express server with Inversify HTTP.

const container: Container = new Container();

const adapter: InversifyExpressHttpAdapter = new InversifyExpressHttpAdapter(
container,
);

const application: express.Application = await adapter.build();

application.listen(3000);

The server is ready to receive requests, but there are no handlers yet. Add a Controller to handle incoming requests.