-
Notifications
You must be signed in to change notification settings - Fork 34
ConfigurationFiles
Mauro edited this page May 27, 2022
·
7 revisions
import {ContainerBuilder, YamlFileLoader} from 'node-dependency-injection'
let container = new ContainerBuilder()
let loader = new YamlFileLoader(container)
await loader.load('/path/to/file.yml')
import {ContainerBuilder, JsonFileLoader} from 'node-dependency-injection'
let container = new ContainerBuilder()
let loader = new JsonFileLoader(container)
await loader.load('/path/to/file.json')
import {ContainerBuilder, JsFileLoader} from 'node-dependency-injection'
let container = new ContainerBuilder()
let loader = new JsFileLoader(container)
await loader.load('/path/to/file.js')
You can now set up the newsletter_manager and mailer services using config files:
services:
mailer:
class: ./Mailer
arguments: ['sendmail']
newsletter_manager:
class: ./NewsletterManager
arguments: ['%fs-extra']
calls:
- { method: 'setMailer', arguments: ['@mailer'] }
{
"services": {
"mailer": {
"class": "./Mailer",
"arguments": ["sendmail"]
},
"newsletter_manager": {
"class": "./NewsletterManager",
"arguments": ["%fs-extra"],
"calls": [
{
"method": "setMailer",
"arguments": ["@mailer"]
}
]
}
}
}
module.exports = {
services: {
mailer: {class: "./Mailer", arguments: ["sendmail"]},
newsletter_manager: {
class: "./NewsletterManager",
arguments: ["%fs-extra"],
calls: [{ method: 'setMailer', arguments: ['@mailer'] }]
}
}
}
Copyright © 2023-2024 Mauro Gadaleta