Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum COMPRESSION_JOBS_TABLE_COLUMN_NAMES {
* @return
*/
const querySql = async <T>(queryString: string) => {
return axios.post<T>("/query/sql", {queryString});
return axios.post<T>("/api/archive-metadata/sql", {queryString});
};

export {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
FastifyPluginAsyncTypebox,
Type,
} from "@fastify/type-provider-typebox";
import {StatusCodes} from "http-status-codes";

import {SqlSchema} from "../../../schemas/archive-metadata.js";


/**
* Archive metadata API routes.
*
* @param fastify
*/
const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const mysqlConnectionPool = fastify.mysql.pool;

fastify.post(
"/sql",
{
schema: {
body: SqlSchema,
response: {
[StatusCodes.OK]: Type.Any(),
},
tags: ["Archive Metadata"],
},
},
async (req, reply) => {
const {queryString} = req.body;
reply.code(StatusCodes.OK);
const [result] = await mysqlConnectionPool.query(queryString);
return result;
},
);
};

export default plugin;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Type} from "@sinclair/typebox";

import {StringSchema} from "./common.js";

/**
* Schema for SQL query request.
*/
const SqlSchema = Type.Object({
queryString: StringSchema,
});

export {
SqlSchema,
};
12 changes: 0 additions & 12 deletions components/log-viewer-webui/server/src/plugins/DbManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ class DbManager {
});
}

/**
* Submits a query to MySQL.
*
* @param queryString
* @return The result from MySQL.
*/
async queryMySql (queryString: string) {
const [result] = await this.#mysqlConnectionPool.query(queryString);
return result;
}


/**
* Submits a stream extraction job to the scheduler and waits for it to finish.
*
Expand Down
15 changes: 0 additions & 15 deletions components/log-viewer-webui/server/src/routes/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ import {
const routes: FastifyPluginAsync = async (app) => {
const fastify = app.withTypeProvider<TypeBoxTypeProvider>();

fastify.post(
"/query/sql",
{
schema: {
body: Type.Object({
queryString: Type.String({minLength: 1}),
}),
},
},
async (req) => {
const {queryString} = req.body;
return await fastify.dbManager.queryMySql(queryString);
},
);

fastify.post("/query/extract-stream", {
schema: {
body: Type.Object({
Expand Down
Loading