laconia
laconia copied to clipboard
How might we abstract require?
Is your feature request related to a problem? Please describe. We usually need to import/require other files, high coupling files.
This discussion are about how we could improve, avoid this.
Describe the solution you'd like Use 'requirejs' updated for nowdays JS. Something like this:
// services/print.js
module.exports = laconiaContext =>
(...args) =>
console.log(...args);
// index.js
// S will import 'services/print'
const app = (event, { S: { print } }) =>
print(event);
const handler = laconia(app)
.register(S)
Good
- low coupling
- easyer to test/mock
Bad
- Tooling
- Mocked unit test are less confident
Ugly
I'm not good with naming things that's why laconiaS (for app 'services') and laconiaR (for 'required')
The discussion are, how could we improve it to add as part of laconia packages, if we should ;-) .