Simple GeoIP Lookup Endpoint
const apimon = require("apimon");
exports.endpoint = (request, response) => {
response.write("Simple GeoIP Lookup Endpoint powered by Apimon.\r\n\r\n");
const path = require('url').parse(request.url).pathname.substr(1);
if(path)
{
apimon.geoip(path).then(result => {
response.write("Country: " + result.country.english_name + " (" + result.country.native_name + ")\r\n");
response.write("Region: " + result.region + "\r\n");
response.write("City: " + result.city.name + "\r\n");
response.write("Zip Code: " + result.zip_code + "\r\n");
response.end("IP address owned by: " + result.as.org);
}).catch(response.end);
}
else
{
response.end("Please provide an IP address.");
}
};
no comments