Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plotlink",
"version": "1.32.1",
"version": "1.32.2",
"private": true,
"workspaces": [
"packages/*"
Expand Down
63 changes: 63 additions & 0 deletions src/app/api/airdrop/activation-status/route.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// @vitest-environment node
import { describe, expect, it, vi } from "vitest";

const mockSingle = vi.fn();

vi.mock("../../../../../lib/supabase", () => ({
createServerClient: () => ({
from: () => ({
select: () => ({ eq: () => ({ single: mockSingle }) }),
}),
}),
}));

import { GET } from "./route";

function makeReq(address?: string) {
const url = address
? `http://localhost/api/airdrop/activation-status?address=${address}`
: "http://localhost/api/airdrop/activation-status";
return new Request(url);
}

describe("GET /api/airdrop/activation-status", () => {
it("returns 4 fields for activated wallet", async () => {
mockSingle.mockResolvedValue({
data: {
x_handle_confirmed_at: "2026-07-01",
x_follow_at: "2026-07-02",
fc_verified_at: "2026-07-03",
activated_at: "2026-07-02",
},
});
const res = await GET(makeReq("0xabc"));
expect(res.status).toBe(200);
const data = await res.json();
expect(data.x_handle_confirmed_at).toBe("2026-07-01");
expect(data.activated_at).toBe("2026-07-02");
});

it("returns all-null for non-existent address", async () => {
mockSingle.mockResolvedValue({ data: null });
const res = await GET(makeReq("0xnonexistent"));
expect(res.status).toBe(200);
const data = await res.json();
expect(data).toEqual({
x_handle_confirmed_at: null,
x_follow_at: null,
fc_verified_at: null,
activated_at: null,
});
});

it("includes Cache-Control: no-store header", async () => {
mockSingle.mockResolvedValue({ data: null });
const res = await GET(makeReq("0xabc"));
expect(res.headers.get("Cache-Control")).toBe("no-store");
});

it("returns 400 when address is missing", async () => {
const res = await GET(makeReq());
expect(res.status).toBe(400);
});
});
32 changes: 32 additions & 0 deletions src/app/api/airdrop/activation-status/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { NextResponse } from "next/server";
import { createServerClient } from "../../../../../lib/supabase";

export async function GET(req: Request) {
const { searchParams } = new URL(req.url);
const address = searchParams.get("address")?.toLowerCase();

if (!address) {
return NextResponse.json({ error: "address parameter required" }, { status: 400 });
}

const supabase = createServerClient();
if (!supabase) {
return NextResponse.json({ error: "Supabase not configured" }, { status: 500 });
}

const { data } = await supabase
.from("pl_activations")
.select("x_handle_confirmed_at, x_follow_at, fc_verified_at, activated_at")
.eq("address", address)
.single();

return NextResponse.json(
{
x_handle_confirmed_at: data?.x_handle_confirmed_at ?? null,
x_follow_at: data?.x_follow_at ?? null,
fc_verified_at: data?.fc_verified_at ?? null,
activated_at: data?.activated_at ?? null,
},
{ headers: { "Cache-Control": "no-store" } },
);
}
Loading