Skip to content

Instantly share code, notes, and snippets.

@crizstian
Created February 9, 2017 04:25
Show Gist options
  • Save crizstian/ac4a6ee5775f604e158d4cdeda757442 to your computer and use it in GitHub Desktop.
Save crizstian/ac4a6ee5775f604e158d4cdeda757442 to your computer and use it in GitHub Desktop.
Example of a stripe charge
const { createContainer, asValue } = require('awilix')
const stripe = require('stripe')
// here we include the stripeSettings
function initDI ({serverSettings, dbSettings, database, models, stripeSettings}, mediator) {
mediator.once('init', () => {
mediator.on('db.ready', (db) => {
const container = createContainer()
container.register({
database: asValue(db),
validate: asValue(models.validate),
ObjectID: asValue(database.ObjectID),
serverSettings: asValue(serverSettings),
// and here we register our stripe module
stripe: asValue(stripe(stripeSettings.secret))
})
mediator.emit('di.ready', container)
})
// more code ..., check the cinema microservice repository for to see the full code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment