Skip to content

Instantly share code, notes, and snippets.

@Pyrolistical
Created November 29, 2016 09:13
Show Gist options
  • Save Pyrolistical/4348d128ee811e6239ba3e8d89d42615 to your computer and use it in GitHub Desktop.
Save Pyrolistical/4348d128ee811e6239ba3e8d89d42615 to your computer and use it in GitHub Desktop.
Factory Function Injection
const MongoClient = require('mongodb').MongoClient
const Controller = require('./controller')
const Service = require('./service')
const Repository = require('./repository')
MongoClient.connect('some mongo url')
.then((db) => {
const repository = Repository(db)
const service = Service(repository)
const controller = Controller(service)
controller.doTheThing()
})
.catch(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment