andyrichardson / andyrichardson/subscriptionless
Add sendMessage handler
- Dominant language
- TypeScript
- Stars
- 93
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
I'm using [architect](https://arc.codes) for my dev environment and infrastructure management. The dev environment has a api gateway, ddb, lambda and sns, simulators. They're incredibly enjoyable to use locally. However, sending websocket messages in the dev environment doesn't work the same way as it does it production and I need to [use it's method](https://arc.codes/docs/en/reference/runtime/node#arc.ws) instead of the AWS Manager object directly.
I'd like to be able to provide my own async function to send messages, so I can use subscriptionless with architect.
The hook could be used to modify the message or prevent sending. I made up some trite examples of why you might want it, but I bet there are real use cases besides the dev server. And of course the simple case of "if the hook is set, just use that hook" works for me.
```ts
const instance = createInstance({
/* ... */
onSendMessage: async ({ message }) => {
// prevent sending
if (containsSensitiveData(message)) {
return false
}
// send through another channel?
if(highPriority(message)){
await fastSend(message)
}
// send normally
return message
},
});
```
Happy to do the PR (or not) if this is something you'd add to the project.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.