Middlewares
withTagInject
Inject tags into the pipeline context
withTagInject injects a static tags map into the context as tagsToInject, making it available to downstream middleware and anything that reads ctx in the chain.
import { withTagInject } from '@betternotify/core/middlewares';
const welcome = rpc
.email()
.input(schema)
.subject(fn)
.template(adapter)
.use(withTagInject({
tags: { environment: 'production', team: 'growth' },
}));Options
Prop
Type
Reading injected tags
Downstream middleware or hooks can read the tags from context:
const withTagLogger: Middleware = async ({ ctx, next }) => {
console.log('tags:', (ctx as { tagsToInject?: Record<string, string> }).tagsToInject);
return next();
};