Engineering manualAPI route source
/api/brands/basic
Exact current route handler: hosted-app/app/api/brands/basic/route.js
Methods: DELETE, GET, POST. Input signals: JSON body, query parameters. Literal response-status signals: none detected.
Source: hosted-app/app/api/brands/basic/route.js. Imports: ../../../../lib/basic-brands.mjs, ../../../../lib/comprehensive-pull.mjs, ../../../../lib/supabase-rest.mjs, next/server. Exact source is shown for inspection; its presence does not prove authentication, validation or live behavior.
All API routes · API and execution contract
// /api/brands/basic — saved basic brand reads.
//
// POST { url } read the public homepage on the server and save it
// GET ?id= | ?domain= the saved read (latest for a domain)
// DELETE ?id= remove one saved read
//
// Saving needs a browser session or an API key with run_pulls; it is free and
// calls no paid provider. Reading needs read_reports. See lib/basic-brands.mjs.
import { NextResponse } from "next/server";
import { supabaseConfigFromEnv } from "../../../../lib/supabase-rest.mjs";
import { bearerTokenFromHeader } from "../../../../lib/comprehensive-pull.mjs";
import { deleteBasicRead, getBasicRead, saveBasicRead } from "../../../../lib/basic-brands.mjs";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
const PRIVATE = { "cache-control": "private, no-store", "x-content-type-options": "nosniff" };
const reply = (result) => NextResponse.json(result.body, { status: result.http_status, headers: PRIVATE });
const tokenOf = (request) => bearerTokenFromHeader(request.headers.get("authorization"));
export async function GET(request) {
const params = new URL(request.url).searchParams;
return reply(await getBasicRead({ token: tokenOf(request), config: supabaseConfigFromEnv(process.env), readId: params.get("id") || "", domain: params.get("domain") || "" }));
}
export async function POST(request) {
const body = await request.json().catch(() => null);
return reply(await saveBasicRead({ token: tokenOf(request), config: supabaseConfigFromEnv(process.env), body: body || {}, env: process.env }));
}
export async function DELETE(request) {
return reply(await deleteBasicRead({ token: tokenOf(request), config: supabaseConfigFromEnv(process.env), readId: new URL(request.url).searchParams.get("id") || "" }));
}