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

@ -69,19 +69,17 @@ export const getServerSideProps: GetServerSideProps = async (
});
});
}
console.log({ query });
const dataResponse = await client.search({
index: "demo_data",
size: 200,
body: { query },
});
console.log({ dataResponse });
res.props.data = dataResponse.body.hits.hits.map((hit) => ({
id: hit._id,
...hit._source,
}));
console.log({ data: res.props.data });
console.log(res.props.data[0]);
return res;
};

View file

@ -22,20 +22,17 @@ export const authOptions: NextAuthOptions = {
Credentials({
name: "Link",
credentials: {
authToken: { label: "AuthToken", type: "text", },
authToken: { label: "AuthToken", type: "text" },
},
async authorize(credentials, req) {
const { headers } = req;
console.log({ headers });
const leafcutterUser = headers?.["x-leafcutter-user"];
const authToken = credentials?.authToken;
if (!leafcutterUser || leafcutterUser.trim() === "") {
console.log("no leafcutter user");
return null;
}
console.log({ authToken });
return null;
/*
try {
@ -48,14 +45,13 @@ export const authOptions: NextAuthOptions = {
return user;
} catch (e) {
console.log({ e });
console.error({ e });
}
return null;
*/
}
})
},
}),
],
secret: process.env.NEXTAUTH_SECRET,
/*
@ -77,4 +73,3 @@ export const authOptions: NextAuthOptions = {
}
},*/
};

View file

@ -302,8 +302,7 @@ export const updateUserVisualization = async (
body,
});
} catch (e) {
// eslint-disable-next-line no-console
console.log({ e });
console.error({ e });
}
return id;

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);
};