mirror of
https://github.com/oceanprotocol/ens-proxy.git
synced 2024-12-02 05:57:34 +01:00
Removing Next.js
This commit is contained in:
parent
510912d93c
commit
043b524219
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.env
|
.env
|
||||||
.vercel
|
.vercel
|
||||||
dist
|
dist
|
||||||
.next
|
|
36
api/_utils.ts
Normal file
36
api/_utils.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { ethers } from 'ethers'
|
||||||
|
import {
|
||||||
|
createClient,
|
||||||
|
dedupExchange,
|
||||||
|
TypedDocumentNode,
|
||||||
|
OperationContext,
|
||||||
|
fetchExchange
|
||||||
|
} from 'urql'
|
||||||
|
|
||||||
|
export async function getProvider(): Promise<any> {
|
||||||
|
const provider = new ethers.providers.InfuraProvider(
|
||||||
|
'homestead',
|
||||||
|
process.env.INFURA_PROJECT_ID
|
||||||
|
)
|
||||||
|
return provider
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchData(
|
||||||
|
query: TypedDocumentNode,
|
||||||
|
variables: any,
|
||||||
|
context: OperationContext
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const client = createClient({
|
||||||
|
url: 'https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph',
|
||||||
|
exchanges: [dedupExchange, fetchExchange]
|
||||||
|
})
|
||||||
|
|
||||||
|
const response = await client.query(query, variables, context).toPromise()
|
||||||
|
console.log('response', response)
|
||||||
|
return response
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetchData: ', error)
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
import { NextApiRequest, NextApiResponse } from 'next'
|
import type { VercelRequest, VercelResponse } from '@vercel/node'
|
||||||
import { getProvider } from './_utils'
|
import { getProvider } from './_utils'
|
||||||
|
|
||||||
export default async function getEnsAddress(
|
export default async function getEnsAddress(
|
||||||
request: NextApiRequest,
|
request: VercelRequest,
|
||||||
response: NextApiResponse
|
response: VercelResponse
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const ensName = request.query.name
|
const ensName = request.query.name
|
@ -1,4 +1,4 @@
|
|||||||
import { NextApiRequest, NextApiResponse } from 'next'
|
import type { VercelRequest, VercelResponse } from '@vercel/node'
|
||||||
import { getProvider } from './_utils'
|
import { getProvider } from './_utils'
|
||||||
|
|
||||||
export async function getEnsName(accountId: string) {
|
export async function getEnsName(accountId: string) {
|
||||||
@ -12,8 +12,8 @@ export async function getEnsName(accountId: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function nameApi(
|
export default async function nameApi(
|
||||||
request: NextApiRequest,
|
request: VercelRequest,
|
||||||
response: NextApiResponse
|
response: VercelResponse
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const accountId = String(request.query.accountId)
|
const accountId = String(request.query.accountId)
|
@ -1,4 +1,4 @@
|
|||||||
import { NextApiRequest, NextApiResponse } from 'next'
|
import type { VercelRequest, VercelResponse } from '@vercel/node'
|
||||||
import { getEnsName } from './name'
|
import { getEnsName } from './name'
|
||||||
import { getEnsTextRecords } from './text'
|
import { getEnsTextRecords } from './text'
|
||||||
|
|
||||||
@ -57,8 +57,8 @@ export async function getEnsProfile(accountId: string): Promise<Profile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function EnsProfileApi(
|
export default async function EnsProfileApi(
|
||||||
request: NextApiRequest,
|
request: VercelRequest,
|
||||||
response: NextApiResponse
|
response: VercelResponse
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const accountId = String(request.query.address)
|
const accountId = String(request.query.address)
|
@ -1,4 +1,4 @@
|
|||||||
import { NextApiRequest, NextApiResponse } from 'next'
|
import type { VercelRequest, VercelResponse } from '@vercel/node'
|
||||||
import { gql, OperationResult } from 'urql'
|
import { gql, OperationResult } from 'urql'
|
||||||
import { fetchData, getProvider } from './_utils'
|
import { fetchData, getProvider } from './_utils'
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ export async function getEnsTextRecords(
|
|||||||
requestPolicy: 'cache-and-network'
|
requestPolicy: 'cache-and-network'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
console.log('result?.data?.domains[0]?.resolver', result)
|
||||||
if (!result?.data?.domains[0]?.resolver) throw 'No ENS text records found'
|
if (!result?.data?.domains[0]?.resolver) throw 'No ENS text records found'
|
||||||
|
|
||||||
// 2. Retrieve the text records.
|
// 2. Retrieve the text records.
|
||||||
@ -48,8 +49,8 @@ export async function getEnsTextRecords(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function ensTextApi(
|
export default async function ensTextApi(
|
||||||
request: NextApiRequest,
|
request: VercelRequest,
|
||||||
response: NextApiResponse
|
response: VercelResponse
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const ensName = String(request.query.name)
|
const ensName = String(request.query.name)
|
5
next-env.d.ts
vendored
5
next-env.d.ts
vendored
@ -1,5 +0,0 @@
|
|||||||
/// <reference types="next" />
|
|
||||||
/// <reference types="next/image-types/global" />
|
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
|
||||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
|
1886
package-lock.json
generated
1886
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -16,20 +16,19 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ethers": "^5.7.0",
|
"ethers": "^5.7.0",
|
||||||
"next": "^12.2.5",
|
|
||||||
"urql": "^2.2.3"
|
"urql": "^2.2.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^18.0.17",
|
"@types/react": "^18.0.17",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
||||||
"@typescript-eslint/parser": "^5.29.0",
|
"@typescript-eslint/parser": "^5.29.0",
|
||||||
|
"@vercel/node": "^2.5.8",
|
||||||
"eslint": "^8.18.0",
|
"eslint": "^8.18.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"husky": "^7.0.0",
|
"husky": "^7.0.0",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"pretty-quick": "^3.1.3",
|
"pretty-quick": "^3.1.3",
|
||||||
"ts-node": "^10.8.1",
|
|
||||||
"typescript": "4.7.3"
|
"typescript": "4.7.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user