Skip to content

Instantly share code, notes, and snippets.

@ceilfors
Last active Sep 10, 2018
Embed
What would you like to do?
better-dependency-injection-with-laconia
const laconia = require("@laconia/core");
// Creates the dependencies
const instances = async () => {
const password = await getPassword();
return { twitterService: new TwitterService(password) };
};
// Declare the dependency you need by destructuring
const handler = ({ twitterService }) => {
return twitterService.getLatestTweets(1000);
};
// Bootstrap laconia
exports.handler = laconia(handler).register(instances);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment