Skip to content

Instantly share code, notes, and snippets.

@kidGodzilla
Last active December 12, 2020 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kidGodzilla/36da0bcb036e15811c61360a8212e081 to your computer and use it in GitHub Desktop.
Save kidGodzilla/36da0bcb036e15811c61360a8212e081 to your computer and use it in GitHub Desktop.
/**
* @api {get} /freemail/:email isFreeMail
* @apiDescription Tests a domain to see if it's a free email or disposible email address
* @apiGroup Utility
* @apiExample {REST} Example usage:
GET https://api.meetingroom365.com/freemail/foo@gmail.com
* @apiParam {String} email The email address you wish to check
* @apiVersion 0.5.0
* @apiSuccessExample {json} Success
*HTTP/1.1 200 OK
{
email: "foo@gmail.com",
isFree: true,
isDisposable: false
}
*/
app.get('/freemail/:email', (req, res) => {
let { email } = req.params;
const freemail = require('freemail');
if (!email.includes('@')) email = 'foo@' + email;
res.send({
email: email,
isFree: freemail.isFree(email),
isDisposable: freemail.isDisposable(email)
});
});
@kidGodzilla
Copy link
Author

kidGodzilla commented Dec 10, 2020

This is just a little Express endpoint that handles free / disposable email checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment