Skip to content

alemarr/ioc-inversify

Repository files navigation

IoC and InversifyJS

A little demo API that implements Inversion of Control (IoC) using InversifyJS and Typescript.

Setup

$ npm install

Run and test API

Run the API with the following command:

$ npm run start

Endpoints

Create a new post

curl --location --request POST 'http://localhost:3000/api/posts' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title": "Proof of Concept",
    "description": "Here goes the description of my new post."
}'

Get the posts list

curl --location --request GET 'http://localhost:3000/api/posts'

UPDATE (May 2022):

Added a few changes to improve this project:

  • Removed dummy endpoint and implemented a new one using POST and handling a basic payload.
  • Split the project into layers for a better structure.
  • Added inversify-express-utils to implement new API endpoints.
  • Added Unit Tests.

This repo is related to my article on Medium about the Inversion of Control principle and InversifyJS.

Author

Alejandro Marr