0.1.0 • Published 9 years ago
email-router v0.1.0
email-router

A router for email addresses.
A lightweight router made for email addresses.
var email = router();
email.on('foo@example.com', function() {
console.log('Hello world');
});
email('f.o.o@example.com');
// "Hello world"Default email resolving includes:
- Ignoring
.(i.e.f.o.o@example.comtofoo@example.com) - Ignoring
+tag(i.e.foo+tag@example.comtofoo@example.com)
Installation
$ npm install --save email-routerAPI
router([options])
Creates a new email router, returning a route function.
options.default(String): Route to use when none match.options.resolve(Function): Alternative resolver torouter.resolve.
var foo = router({
default: 'foo@example.com',
resolve: function(address) {/* ... */}
});router.resolve(address)
The default email resolver.
address(String): The email address to be resolved.
router.resolve('f.o.o@example.com');
// "foo@example.com"route(address, args)
Resolve address and run the route handler(s) with args bound using route.on.
address(String): Email address being routed to that gets resolved.args(Array): Arguments to pass to the route handler(s).
var route = router(/* ... */);
// ... bind routes with `route.on`
route('f.o.o@example.com', 1, 2, 3);route.on(address, handler)
Create a handler to the resolved address and executed with route.
address(String): The resolved address to bind the handler to.handler(Function): Function to be triggered when routed to.
var route = router(/* ... */);
route.on('foo@example.com', bar => console.log('Hello %s', bar));
route('f.o.o@example.com', 'world');
// "Hello world"License
MIT © Jamen Marzonie
0.1.0
9 years ago