ens-proxy/api/address.ts
2022-08-24 17:05:52 +03:00

19 lines
520 B
TypeScript

import type { VercelRequest, VercelResponse } from '@vercel/node'
import { getProvider } from './_utils'
export default async function getEnsAddress(
request: VercelRequest,
response: VercelResponse
) {
try {
const ensName = request.query.name
const provider = await getProvider()
const address = await provider.resolveName(ensName)
response.setHeader('Cache-Control', 'max-age=0, s-maxage=86400')
response.status(200).send({ address })
} catch (error) {
response.send({ error })
}
}