GithubHelp home page GithubHelp logo

zazoomauro / node-dependency-injection-express-middleware Goto Github PK

View Code? Open in Web Editor NEW
9.0 5.0 2.0 1.48 MB

A Node Dependency Injection middleware for Express

License: MIT License

JavaScript 100.00%
express middleware node dependency injection service container console inversion-of-control service-locator

node-dependency-injection-express-middleware's People

Contributors

dependabot[bot] avatar dornasportse avatar zazoomauro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

node-dependency-injection-express-middleware's Issues

How to require the middleware instead of import?

I'm trying to use require instead of import and I struggle with it. I'm also pretty new to node.js

#app.js

const Express = require('express');

const app = Express();

const NDIMiddleware =  require('node-dependency-injection-express-middleware');

const services = {serviceFilePath: './resources/services.yml'}

And I don't know where to go from here without throwing any errors like in those examples

#app.js
app.use(new NDIMiddleware.default(services).middleware());
#services.yml
services:
  mailHandler:
    class:     './src/MailHandler'
#/src/MailHandler.js
class MailHandler {
    constructor() {}
}


module.exports = MailHandler;
> [email protected] start /home/paul/GIT/dpasw
> node ./bin/www

internal/modules/cjs/loader.js:1032
  throw err;
  ^

Error: Cannot find module 'src/MailHandler'
Require stack:
- /home/user/GIT/project/node_modules/node-dependency-injection/dist/lib/Loader/FileLoader.js
- /home/user/GIT/project/node_modules/node-dependency-injection/dist/lib/Loader/JsFileLoader.js
- /home/user/GIT/project/node_modules/node-dependency-injection/dist/lib/index.js
- /home/user/GIT/project/node_modules/node-dependency-injection-express-middleware/dist/index.js
- /home/user/GIT/project/app.js
- /home/user/GIT/project/bin/www
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
    at Function.Module._load (internal/modules/cjs/loader.js:898:27)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.