{"repo":"jeffijoe/awilix-express","free":true,"listed":false,"github":"https://github.com/jeffijoe/awilix-express","clone":"git clone https://github.com/jeffijoe/awilix-express.git","description":"Awilix helpers/middleware for Express","language":"TypeScript","stars":127,"topics":["awilix","express","dependency-injection","di","inversion-of-control"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"awilix-express Awilix helpers, router and scope-instantiating middleware for Express . 🐨 ✨ NEW IN V1 : first-class router support with auto-loading! 🚀 Table of Contents - awilix-express - Table of Contents - Installation - Basic Usage - Awesome Usage - Why do I need it? - Manual - Using awilix-express - API - Contributing - npm run scripts - Author Installation Basic Usage Add the middleware to your Express app. Then in your route handlers... Awesome Usage As of awilix-express@1.0.0 , we ship with Express.Router bindings for [ awilix-router-core ][awilix-router-core]! This is cool because now your routing setup can be streamlined with first-class Awilix support! The Awilix-based router comes in 2 flavors: a builder and ESNext decorators . routes/todos-api.js - demos the builder pattern routes/users-api.js - demos the decorator pattern server.js - CommonJS / synchronous server.js - ESM / async When using ES modules, pass esModules: true . This makes loadControllers return a Promise , so you'll need to await it. Please see the [ awilix-router-core ][awilix-router-core] docs for information about the full API. Why do I need it? You can certainly use Awilix with Express without this library, but follow along and you might see why it's useful. Imagine this simple imaginary Todos app, written in ES6: So the problem with the above is that the TodosService needs a currentUser for it to function. Let's first try solving this manually, and then with awilix-express . Manual This is ho","default_branch":null,"files":null,"tree":[],"storefront":"/r/jeffijoe","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/jeffijoe/awilix-express/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}