#Question about Email Workers

2 messages · Page 1 of 1 (latest)

subtle jackal
#

I currently have a worker setup for prod and staging using the Hono framework to handle backend logic such as auth/session handling/supabase db calls/etc. I’d like to use email routing to process emails sent to a custom address and then process them in one of my hono routes (that’s the general idea). My question is: should I implement the logic for email processing in the same worker or create a separate Email Worker? I currently have this setup, but I’m not entirely sure on 1. if it’ll work and 2. if it’s even best practice. I AM HERE TO LEARN

import { Hono } from 'hono'

const app = new Hono()
//...

export default {
fetch(request, env, ctx) {return app.fetch(request, env, ctx)
}
async email(message, env, ctx) {
// logic to be implemented
}

junior musk
#

Entirely your choice, I'm not sure there's a clear advantage one way or another from this description. You could always start with the logic colocated and then move it and use service bindings if it becomes too complex or you want another worker.