Updates
This commit is contained in:
@@ -26,9 +26,7 @@ export default async function googleLogin({
|
||||
serverRes,
|
||||
loginFailureReason,
|
||||
}: Param) {
|
||||
const client = new OAuth2Client(
|
||||
process.env.NEXT_PUBLIC_DSQL_GOOGLE_CLIENT_ID
|
||||
);
|
||||
const client = new OAuth2Client(process.env.DSQL_GOOGLE_CLIENT_ID);
|
||||
let isGoogleAuthValid = false;
|
||||
let newFoundUser = null;
|
||||
|
||||
@@ -39,7 +37,7 @@ export default async function googleLogin({
|
||||
try {
|
||||
const ticket = await client.verifyIdToken({
|
||||
idToken: reqBody.token,
|
||||
audience: process.env.NEXT_PUBLIC_DSQL_GOOGLE_CLIENT_ID, // Specify the CLIENT_ID of the app that accesses the backend
|
||||
audience: process.env.DSQL_GOOGLE_CLIENT_ID, // Specify the CLIENT_ID of the app that accesses the backend
|
||||
// Or, if multiple clients access the backend:
|
||||
//[CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3]
|
||||
});
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import getQueue from "./get-queue";
|
||||
import {
|
||||
DSQL_DATASQUIREL_PROCESS_QUEUE,
|
||||
DsqlTables,
|
||||
} from "../../../types/dsql";
|
||||
import dsqlCrud from "../../../utils/data-fetching/crud";
|
||||
import numberfy from "../../../utils/numberfy";
|
||||
|
||||
type Param = {
|
||||
queue: DSQL_DATASQUIREL_PROCESS_QUEUE;
|
||||
userId: string | number;
|
||||
dummy?: boolean;
|
||||
};
|
||||
|
||||
export default async function addQueue({ queue, userId, dummy }: Param) {
|
||||
const tableName: (typeof DsqlTables)[number] = "process_queue";
|
||||
|
||||
const existingQueueRes = dummy
|
||||
? undefined
|
||||
: ((await getQueue({
|
||||
query: {
|
||||
query: {
|
||||
user_id: {
|
||||
value: String(userId),
|
||||
},
|
||||
job_type: {
|
||||
value: String(queue.job_type),
|
||||
},
|
||||
},
|
||||
},
|
||||
})) as DSQL_DATASQUIREL_PROCESS_QUEUE[] | undefined);
|
||||
|
||||
const existingQueue = existingQueueRes?.[0];
|
||||
|
||||
if (existingQueue?.id && !dummy) return undefined;
|
||||
|
||||
const addQueueRes = await dsqlCrud<DSQL_DATASQUIREL_PROCESS_QUEUE>({
|
||||
action: "insert",
|
||||
table: tableName,
|
||||
data: { ...queue, user_id: numberfy(userId) },
|
||||
});
|
||||
|
||||
return addQueueRes;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import dsqlCrud from "../../../utils/data-fetching/crud";
|
||||
import getQueue from "./get-queue";
|
||||
import {
|
||||
DSQL_DATASQUIREL_PROCESS_QUEUE,
|
||||
DsqlTables,
|
||||
} from "../../../types/dsql";
|
||||
|
||||
type Param = {
|
||||
queueId: string | number;
|
||||
userId: string | number;
|
||||
};
|
||||
|
||||
export default async function deleteQueue({ queueId, userId }: Param) {
|
||||
const tableName: (typeof DsqlTables)[number] = "process_queue";
|
||||
|
||||
const existingQueue = (await getQueue({ userId, queueId })) as
|
||||
| DSQL_DATASQUIREL_PROCESS_QUEUE
|
||||
| undefined;
|
||||
|
||||
if (!existingQueue?.id) return false;
|
||||
|
||||
const deleteQueueRes = await dsqlCrud<DSQL_DATASQUIREL_PROCESS_QUEUE>({
|
||||
action: "delete",
|
||||
table: tableName,
|
||||
targetId: existingQueue.id,
|
||||
});
|
||||
|
||||
return Boolean(deleteQueueRes?.success);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import {
|
||||
DSQL_DATASQUIREL_PROCESS_QUEUE,
|
||||
DsqlTables,
|
||||
} from "../../../types/dsql";
|
||||
import dsqlCrud from "../../../utils/data-fetching/crud";
|
||||
import { DsqlCrudQueryObject, ServerQueryQueryObject } from "../../../types";
|
||||
|
||||
type Param = {
|
||||
queueId?: string | number;
|
||||
userId?: string | number;
|
||||
query?: DsqlCrudQueryObject<DSQL_DATASQUIREL_PROCESS_QUEUE>;
|
||||
single?: boolean;
|
||||
};
|
||||
|
||||
export default async function getQueue({
|
||||
queueId,
|
||||
userId,
|
||||
query,
|
||||
single,
|
||||
}: Param) {
|
||||
const tableName: (typeof DsqlTables)[number] = "process_queue";
|
||||
|
||||
let queryQuery: ServerQueryQueryObject<DSQL_DATASQUIREL_PROCESS_QUEUE> = {};
|
||||
|
||||
if (queueId) {
|
||||
queryQuery = { ...queryQuery, ...{ id: { value: String(queueId) } } };
|
||||
}
|
||||
|
||||
if (userId) {
|
||||
queryQuery = {
|
||||
...queryQuery,
|
||||
...{ user_id: { value: String(userId) } },
|
||||
};
|
||||
}
|
||||
|
||||
const getQueue = await dsqlCrud<DSQL_DATASQUIREL_PROCESS_QUEUE>({
|
||||
action: "get",
|
||||
table: tableName,
|
||||
query: {
|
||||
...query,
|
||||
query: {
|
||||
...query?.query,
|
||||
...queryQuery,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const queuePayload = getQueue?.payload as
|
||||
| DSQL_DATASQUIREL_PROCESS_QUEUE[]
|
||||
| undefined;
|
||||
|
||||
return queueId || single ? queuePayload?.[0] : queuePayload;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import dsqlCrud from "../../../utils/data-fetching/crud";
|
||||
import {
|
||||
DSQL_DATASQUIREL_PROCESS_QUEUE,
|
||||
DsqlTables,
|
||||
} from "../../../types/dsql";
|
||||
|
||||
type Param = {
|
||||
queueId: string | number;
|
||||
queue: DSQL_DATASQUIREL_PROCESS_QUEUE;
|
||||
};
|
||||
|
||||
export default async function updateQueue({ queueId, queue }: Param) {
|
||||
const tableName: (typeof DsqlTables)[number] = "process_queue";
|
||||
|
||||
const updateQueueRes = await dsqlCrud<DSQL_DATASQUIREL_PROCESS_QUEUE>({
|
||||
action: "update",
|
||||
table: tableName,
|
||||
targetId: queueId,
|
||||
data: queue,
|
||||
});
|
||||
|
||||
return Boolean(updateQueueRes?.success);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export default function sqlGenerator<
|
||||
>({ tableName, genObject, dbFullName }: Param<T>): Return {
|
||||
if (!genObject) return undefined;
|
||||
|
||||
const finalQuery = genObject.query ? genObject.query : undefined;
|
||||
const finalQuery = genObject?.query ? genObject.query : undefined;
|
||||
|
||||
const queryKeys = finalQuery ? Object.keys(finalQuery) : undefined;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user