feat: add isAdmin column to token entity; implement migration for isAdmin; enhance logging and error handling in query execution; update query plugin to support new logging structure
This commit is contained in:
@ -5,6 +5,8 @@ import "module/squel";
|
||||
import "plugin/db";
|
||||
import "plugin/axios";
|
||||
import "plugin/session";
|
||||
import "plugin/query";
|
||||
import { query } from "express";
|
||||
|
||||
function createSQL(id) {
|
||||
return squel.select().from("test").where("id = ?", id).toString();
|
||||
@ -15,6 +17,8 @@ async function main(input, headers) {
|
||||
|
||||
await db.query("START TRANSACTION");
|
||||
|
||||
await query.run("d079b709-eba3-49be-9f84-08ac6a64a8a8", input);
|
||||
|
||||
// log(await db.query('insert into test (name) values ("Test")'));
|
||||
|
||||
log(new Date().toISOString());
|
||||
@ -28,9 +32,9 @@ async function main(input, headers) {
|
||||
|
||||
await session.set("test", 1);
|
||||
|
||||
const res = await db.query(`
|
||||
SELECT SLEEP(10000);
|
||||
`);
|
||||
// const res = await db.query(`
|
||||
// SELECT SLEEP(10000);
|
||||
// `);
|
||||
|
||||
log(new Date().toISOString());
|
||||
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
// import createDatabase from "../functions/createDatabase";
|
||||
// import createDatabaseNode from "../functions/createDatabaseNode";
|
||||
// import createProject from "../functions/createProject";
|
||||
import createQuery from "../functions/createQuery";
|
||||
// import createQuery from "../functions/createQuery";
|
||||
// import databaseMigrationUp from "../functions/databaseMigrationUp";
|
||||
import runQuery from "../functions/runQuery";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
// import * as fs from "fs";
|
||||
// import * as path from "path";
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
@ -34,15 +34,17 @@ import * as path from "path";
|
||||
|
||||
// console.log("Migrations applied:", migrationResult);
|
||||
|
||||
const payloadPath = path.join(__dirname, "case1-payload.js");
|
||||
const query = await createQuery(
|
||||
{ token: "04c38f93-f2fb-4d2c-a8e2-791effa35239" },
|
||||
fs.readFileSync(payloadPath, { encoding: "utf-8" })
|
||||
);
|
||||
// const payloadPath = path.join(__dirname, "case1-payload.js");
|
||||
// const query = await createQuery(
|
||||
// { token: "c69c2c75-9b30-4aa5-9641-0a931f5aad40" },
|
||||
// fs.readFileSync(payloadPath, { encoding: "utf-8" })
|
||||
// );
|
||||
|
||||
console.log(query);
|
||||
// console.log(query);
|
||||
|
||||
const result = await runQuery(query.id, { id: 1 });
|
||||
const result = await runQuery("66e651f0-261b-4ebd-9749-077abffaddc2", {
|
||||
id: 1,
|
||||
});
|
||||
|
||||
console.log("Query Result:", result.data);
|
||||
console.log("headers:", result.headers);
|
||||
|
||||
@ -9,7 +9,7 @@ export default async (project: { token: string }, source: string) => {
|
||||
source,
|
||||
projectToken: project.token,
|
||||
},
|
||||
{ headers: { "x-api-token": "efbeccd6-dde1-47dc-b3aa-4fbd773d5429" } }
|
||||
{ headers: { "x-api-token": "43c2e96e-af25-4467-9103-1479daa6288d" } }
|
||||
);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
|
||||
@ -8,8 +8,8 @@ export default async (token: string, queryData: Record<string, any>) => {
|
||||
queryData,
|
||||
{
|
||||
headers: {
|
||||
"x-api-token": "efbeccd6-dde1-47dc-b3aa-4fbd773d5429",
|
||||
Cookie: `x-session-id=psaCHcYFMrt6RnUz_1760094020243`,
|
||||
"x-api-token": "43c2e96e-af25-4467-9103-1479daa6288d",
|
||||
Cookie: `x-session-id=gTEd90aRJFmLzJKu_1760193754588`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user