Update logging

This commit is contained in:
Darren Clarke 2025-01-22 17:50:38 +01:00
parent def602c05e
commit 810a333429
39 changed files with 85 additions and 139 deletions

View file

@ -1,15 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
export const GET = async (req: NextRequest) => {
const validDomains = "localhost";
console.log({ req });
const validDomains = "localhost";
return NextResponse.json({ response: "ok" });
return NextResponse.json({ response: "ok" });
};
export const POST = async (req: NextRequest) => {
const validDomains = "localhost";
console.log({ req });
const validDomains = "localhost";
return NextResponse.json({ response: "ok" });
return NextResponse.json({ response: "ok" });
};

View file

@ -2,10 +2,9 @@ import { NextResponse } from "next/server";
import { getTrends } from "app/_lib/opensearch";
export const GET = async () => {
const results = await getTrends(5);
console.log({ results });
const results = await getTrends(5);
NextResponse.json(results);
NextResponse.json(results);
};
export const dynamic = 'force-dynamic';
export const dynamic = "force-dynamic";

View file

@ -15,8 +15,8 @@ export const POST = async (req: NextRequest) => {
rejectUnauthorized: false,
},
headers: {
authorization
}
authorization,
},
});
const succeeded = [];
@ -28,11 +28,15 @@ export const POST = async (req: NextRequest) => {
const country = ticket.country[0] ?? "none";
// @ts-expect-error
const translatedCountry = taxonomy.country[country]?.display ?? "none";
const countryDetails: any = unRegions.find((c) => c.name === translatedCountry);
const countryDetails: any = unRegions.find(
(c) => c.name === translatedCountry,
);
const augmentedTicket = {
...ticket,
region: countryDetails['sub-region']?.toLowerCase().replace(" ", "-") ?? null,
continent: countryDetails.region?.toLowerCase().replace(" ", "-") ?? null,
region:
countryDetails["sub-region"]?.toLowerCase().replace(" ", "-") ?? null,
continent:
countryDetails.region?.toLowerCase().replace(" ", "-") ?? null,
};
const out = await client.create({
id: uuid(),
@ -40,10 +44,9 @@ export const POST = async (req: NextRequest) => {
refresh: true,
body: augmentedTicket,
});
console.log(out);
succeeded.push(id);
} catch (e) {
console.log(e);
console.error(e);
failed.push(id);
}
}
@ -52,4 +55,3 @@ export const POST = async (req: NextRequest) => {
return NextResponse.json(results);
};