Skip to content

Commit

Permalink
update: update attestation get by default by schema uid and recipient…
Browse files Browse the repository at this point in the history
… address
  • Loading branch information
mrisqid committed Aug 10, 2024
1 parent 693880a commit 594a011
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions apps/haus/src/app/api/attestation/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ export async function POST(request: Request) {
}
}

interface WhereType {
schemaId: {
equals: string | undefined
}
recipient?: {
equals: string | undefined
}
}

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams
const query = `
Expand All @@ -85,19 +94,24 @@ export async function GET(request: NextRequest) {
`

try {
// schema uid: ?uid=xxxxxxxxxxxxxxxxxxxxxx
const uid = searchParams.get('uid')
if (!SCHEMA_UID) return

if (!uid) {
return NextResponse.json({ message: 'Schema UID is required' }, { status: 400 })
const where: WhereType = {
schemaId: {
equals: SCHEMA_UID,
},
}

// schema recipient: ?recipient=xxxxxxxxxxxxxxxxxxxxxx
const recipient = searchParams.get('recipient')
if (recipient) where.recipient = { equals: searchParams.get('recipient') || undefined }

const response = await axios.post(
QUERY_ENDPOINT,
{
query,
variables: {
where: { schemaId: { equals: uid } },
where,
orderBy: [{ timeCreated: 'desc' }],
},
},
Expand Down

0 comments on commit 594a011

Please sign in to comment.