Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-dependency-injection-express-middleware

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-dependency-injection-express-middleware

Node Dependency Injection Express Middleware

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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
containerReferenceAsServicefalsebooleanfalse
defaultDirfalsestringnull

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(),
  containerReferenceAsService: true,
  defaultDir: '/some/cool/dir',
}
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

Package last updated on 12 Apr 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc