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('[email protected]', function() {
console.log('Hello world');
});
email('[email protected]');
// "Hello world"Default email resolving includes:
- Ignoring
.(i.e.[email protected]to[email protected]) - Ignoring
+tag(i.e.[email protected]to[email protected])
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: '[email protected]',
resolve: function(address) {/* ... */}
});router.resolve(address)
The default email resolver.
address(String): The email address to be resolved.
router.resolve('[email protected]');
// "[email protected]"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('[email protected]', 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('[email protected]', bar => console.log('Hello %s', bar));
route('[email protected]', 'world');
// "Hello world"License
MIT © Jamen Marzonie
0.1.0
9 years ago