-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A DRYer way to import functions #6
Comments
Adding my two cents here for @philippemiguet and for transparency 😄 I agree that current convention adds a bit of boilerplate to the I am sharing an alternative approach that also address points 2 and 3 form the OP. It does not really removes all the boilerplate but packs code a bit 😁
With this approach, all the wiring is explicit, but the The dynamic loading that Dan suggested would, of course, make this even more DRY, but also a bit more magic and require a (breaking?) |
Riffing on the approach here, we could push a 2.0 version that might enforce every package in a directory to wrap their function in // /rpc/createAccount.js
const { method } = require('@bufferapp/rpc')
module.exports = method(
'createAccount',
'Create a new global Buffer account',
async ({ email, password }) => {
const account = new Account({ email, password })
await account.save()
return account.toJSON()
}
) This would allow us to still use the |
@djfarrelly, that's a great intermediary step, I've seen engineers doing that already in different repositories 👍 |
Extracting an idea from https://github.com/bufferapp/core-authentication-service/issues/15, what if we had a DRYer (don't repeat yourself) way to import a bunch of RPC functions?
Right now, the way we're doing things, we've set up projects to require 3 pieces in place:
./src/rpc/index.js
(example):3.5. BONUS - Why do we need to use
method('methodName', methodName)
?Question: - Why do we need to repeat ourselves so much?
Idea - Can we remove most of these steps by providing a simpler way to do this?
The text was updated successfully, but these errors were encountered: