From 246b200d92ba0680f717dad860d31008b98f72b3 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 1 Oct 2021 15:38:58 +0200 Subject: [PATCH] eth.link api --- packages/ipfs-api/src/server.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/ipfs-api/src/server.ts b/packages/ipfs-api/src/server.ts index 273237b3..aec3e9c7 100644 --- a/packages/ipfs-api/src/server.ts +++ b/packages/ipfs-api/src/server.ts @@ -1,5 +1,5 @@ import cors from "cors"; -import express, { Request, Response } from "express"; +import express, { Request, response, Response } from "express"; import fs from "fs"; import got from "got"; import { extension as toExtension } from "mime-types"; @@ -34,9 +34,18 @@ require("dotenv").config(); return handleGetLink(req, res, recordsDB); }); - app.get("/ipfs/name/resolve/:name", (req: Request, res: Response) => { - console.log(`${IPFS_INTERNAL_API}/api/v0/name/resolve?arg=${req.params.name}`); - return got.post(`${IPFS_INTERNAL_API}/api/v0/name/resolve?arg=${req.params.name}`).json(); + app.get("/ipfs/eth/dns-query/:name", async (req: Request, res: Response) => { + try { + const response = await got(`https://eth.link/dns-query?type=TXT&name=${req.params.name}`, { + headers: { "content-type": "application/dns-json" }, + }).json(); + + res.status(200).send(response); + } catch (error) { + console.log(error); + + res.status(400); + } }); // start the server