-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (33 loc) · 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const express = require('express')
const cors = require('cors')
const fs = require('fs')
const readline = require('readline');
var app = express();
var PORT = process.env.PORT || 3001;
app.use(cors())
var domains = []
const readInterface = readline.createInterface({
input: fs.createReadStream('./domains.txt'),
output: process.stdout,
console: false
});
readInterface.on('line', function (line) {
// console.log(line);
domains.push(line)
});
console.log(domains.toString())
app.get("/:email", function (req, res) {
var email = req.params.email;
var emaild = email.toString().split("@")
if (emaild.length == 0) {
return res.json({ "message": "invalid email" })
}
if (domains.includes(emaild[1])) {
return res.json({ "message": "temp email" })
}
return res.json({ "message": "valid email" })
})
app.get("/", function (req, res) {
res.send("<body>Welcome to temp email detector. If you are suffering from users with themp emails then you came to the right place <br> Just send a GET request to /email and it will return the status of the email whether it's or invalid email</body>")
})
app.listen(PORT, () => console.log("Server Running on Port: " + PORT));