Socket
Socket
Sign inDemoInstall

dependency-injection-express-middleware

Package Overview
Dependencies
21
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dependency-injection-express-middleware

Node Dependency Injection Express Middleware


Version published
Weekly downloads
1
Maintainers
1
Install size
2.10 MB
Created
Weekly downloads
 

Readme

Source

Node Dependency Injection Express Middleware

NDI Logo

A Node Dependency Injection middleware for Express

Npm Version Build Status Dependencies DevDependencies Code Coverage Maintainability Coding Standard Known Vulnerabilities Npm Downloads License

Installation

npm install --save node-dependency-injection-express-middleware

Usage

Minimal configuration
import NodeInjectionMiddleware from 'node-dependency-injection-express-middleware'
import express from 'express'

const app = express()

const options = {serviceFilePath: 'some/path/to/config.yml'}
app.use(new NodeInjectionMiddleware(options).middleware())

Options

NameRequiredType ValueDefault Value
serviceFilePathtruestring
compilefalsebooleanfalse
compilerPassfalsearray[]
loggerfalseclass or objectnull

How to use all options

import MyCustomPass from 'CompilerPass/MyCustomPass'
import AnotherAwesomePass from 'CompilerPass/AnotherAwesomePass'
import MyCustomLogger from 'MyCustomLogger'
import NDIMiddleware from 'node-dependency-injection-express-middleware'
import express from 'express'

const app = express()

const options = {
  serviceFilePath: 'some/path/to/config.yml', 
  compile: true,
  compilerPass: [new MyCustomPass(), new AnotherAwesomePass()],
  logger: new MyCustomLogger()
}
app.use(new NDIMiddleware(options).middleware())

How to get the container

app.get('/some/action', (req, res, next) => {
  const container = req.container
  const myAwesomeService = container.get('some.awesome.service')
  ...
})

Please, read the FULL DOCUMENTATION

Resources

Keywords

FAQs

Last updated on 08 Jun 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc