Created
April 24, 2020 20:57
-
-
Save kenanhancer/71a267da83bd0312d8672dc10bcde125 to your computer and use it in GitHub Desktop.
nut-ioc loading dependencies with directory path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.ServiceName = ""; //fileName if empty,null or undefined | |
module.exports.Service = ({ helper }) => | |
({ | |
sayHello: ({ firstName, lastName }) => { | |
const fullName = helper.getFullName({ firstName, lastName }); | |
return `Hello ${fullName}`; | |
}, | |
sayGoodbye: ({ firstName, lastName }) => { | |
const fullName = helper.getFullName({ firstName, lastName }); | |
return `Goodbye, ${fullName}`; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.ServiceName = ""; //fileName if empty,null or undefined | |
module.exports.Service = ({ | |
getFullName: ({ firstName, lastName }) => { | |
return `${firstName} ${lastName}`; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nutIoc = require('nut-ioc'); | |
const nutIocContainer = nutIoc(); | |
const mainAsync = async () => { | |
const ignoredDependencies = ['node_modules', | |
'.env', | |
'*.json', | |
'.idea', | |
'.git', | |
'.gitignore', | |
'*.iml', | |
'.*', | |
'*.md', | |
'LICENSE']; | |
nutIocContainer.use({ dependencyPath: './', ignoredDependencies }); | |
const { greetingService } = await nutIocContainer.build(); | |
const helloMsg = greetingService.sayHello({ firstName: "kenan", lastName: "hancer" }); | |
console.log(helloMsg); | |
const goodBydMsg = greetingService.sayGoodbye({ firstName: "kenan", lastName: "hancer" }); | |
console.log(goodBydMsg); | |
}; | |
mainAsync(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment