mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 21:14:23 +00:00
Some checks are pending
Build and Push Docker Image / build-and-push (push) Waiting to run
missing? well, all the actions that requires the data to be sent to the server is still not there yet. Tried to add onboarding, but I have just no idea how to do it (Maybe I can do it w/ a video?
33 lines
701 B
TypeScript
33 lines
701 B
TypeScript
import sql from "./postgres";
|
|
|
|
export async function checkIfUserHasCustomGroqKey(token?: string) {
|
|
if (!token) {
|
|
return {
|
|
status: false,
|
|
customApi: "",
|
|
};
|
|
}
|
|
const checkRealToken = await sql`
|
|
select * from usertokens
|
|
where token = ${token}
|
|
`;
|
|
if (checkRealToken.length === 0) {
|
|
return {
|
|
status: false,
|
|
customApi: "",
|
|
};
|
|
}
|
|
const fetchUserToken = await sql`
|
|
select groq_api_key from user_other_data
|
|
where username = ${checkRealToken[0].username}`;
|
|
if (fetchUserToken.length === 0) {
|
|
return {
|
|
status: false,
|
|
customApi: "",
|
|
};
|
|
}
|
|
return {
|
|
status: true,
|
|
customApi: fetchUserToken[0].groq_api_key,
|
|
};
|
|
}
|