Skip to content

Commit

Permalink
WIP: add a prototype edge function using the solflare token SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
mcintyre94 committed Jul 19, 2023
1 parent 47006f0 commit 361bed5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/api/token-search-node/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NextRequest, NextResponse } from "next/server"
import { Client, ChainId, UtlConfig } from '@solflare-wallet/utl-sdk';

export async function GET(req: NextRequest) {
const params = req.nextUrl.searchParams;
const query = params.get('query');
if (!query) return NextResponse.json([]);

const config: UtlConfig = {
...new UtlConfig(),
chainId: ChainId.MAINNET // TODO: query param
};
const tokenClient = new Client(config);
const tokens = await tokenClient.searchMints(query, { start: 0, limit: 20 });

return NextResponse.json(tokens);
}
22 changes: 22 additions & 0 deletions app/api/token-search/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NextRequest, NextResponse } from "next/server"
import { Client, ChainId, UtlConfig } from '@solflare-wallet/utl-sdk';


export const config = {
runtime: 'edge',
}

export async function GET(req: NextRequest) {
const params = req.nextUrl.searchParams;
const query = params.get('query');
if (!query) return NextResponse.json([]);

const config: UtlConfig = {
...new UtlConfig(),
chainId: ChainId.MAINNET // TODO: query param
};
const tokenClient = new Client(config);
const tokens = await tokenClient.searchMints(query, { start: 0, limit: 20 });

return NextResponse.json(tokens);
}

0 comments on commit 361bed5

Please sign in to comment.