23 lines
536 B
TypeScript
23 lines
536 B
TypeScript
#!/usr/bin/env runts -- --allow-all
|
|
|
|
import {log} from "../libraries/deno-commons-mod.ts";
|
|
|
|
interface Ip {
|
|
status: number;
|
|
message: string;
|
|
ip: string;
|
|
userAgent: string;
|
|
}
|
|
|
|
async function main() {
|
|
const ipResponse = await fetch("https://hatter.ink/ip/ip.jsonp");
|
|
if (ipResponse.status !== 200) {
|
|
log.error(`Failed to fetch ip response: ${ipResponse.status}`);
|
|
} else {
|
|
const ip = await ipResponse.json() as Ip;
|
|
log.info(`IP address: ${ip.ip}`);
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|