NamesMT / hono-adapter-aws-lambda

MIT License
7 stars 0 forks source link

[RFC] Improving/rethinking the trigger events processing #10

Closed NamesMT closed 1 week ago

NamesMT commented 1 month ago

The current implementation simply declares a custom method (TRIGGER) and lets hono internal processes mostly everything, this approach allows a familiar syntax with normal hono routes and allowing using the same processing logic via with the current adapter but poses some limitation:

In lambda-voie, I designed the .eventRoute (trigger events) processing to be able to register multiple routes for the same eventSource (like: aws:s3), so that we could do many things for the same event and it would returns an object containing all responses from all registered handlers, something like:

app.eventRoute('aws:s3', 'log')
app.eventRoute('aws:s3', 'copyToPrivateStoreIfNeeded') // If condition met then copy and returns the new path
app.eventRoute('aws:s3', 'emailIfNeeded') // If condition met then sends email and returns true

One event comes in and it returns something like:

const res = {
  log: true,
  copyToPrivateStoreIfNeeded: "a/b/c.file",
  emailIfNeeded: false,
}

It was amazing and supports the usecase of a complex applications, like what if both api/book/* and api/user/* both wants to register a trigger handler on aws:s3?.

I hope we could bring it to this adapter too.

NamesMT commented 1 month ago

I have just released a canary version for the PoC of the new processing of trigger routes, here is some notable features: