mirror of
https://github.com/oceanprotocol/ens-proxy.git
synced 2024-11-15 09:45:02 +01:00
20 lines
589 B
TypeScript
20 lines
589 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)
|
|
if (!address) throw `No address found for "${ensName}"`
|
|
|
|
response.setHeader('Cache-Control', 'max-age=0, s-maxage=86400')
|
|
response.status(200).send(address)
|
|
} catch (error) {
|
|
response.status(500).send(`${error}`)
|
|
}
|
|
}
|