test(datamart): more work on datamart setup
This commit is contained in:
@@ -1,7 +1,32 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { Express } from "express";
|
||||
import { db } from "../db/db.controller.js";
|
||||
import { datamart } from "../db/schema/datamart.schema.js";
|
||||
import { apiReturn } from "../utils/returnHelper.utils.js";
|
||||
import addQuery from "./datamartAdd.route.js";
|
||||
import runQuery from "./getDatamart.route.js";
|
||||
|
||||
export const setupDatamartRoutes = (baseUrl: string, app: Express) => {
|
||||
//setup all the routes
|
||||
|
||||
app.use(`${baseUrl}/api/datamart`, runQuery);
|
||||
app.use(`${baseUrl}/api/datamart`, addQuery);
|
||||
|
||||
// just sending a get on datamart will return all the queries that we can call.
|
||||
app.get(`${baseUrl}/api/datamart`, async (_, res) => {
|
||||
const queries = await db
|
||||
.select()
|
||||
.from(datamart)
|
||||
.where(eq(datamart.active, true));
|
||||
|
||||
return apiReturn(res, {
|
||||
success: true,
|
||||
level: "info",
|
||||
module: "datamart",
|
||||
subModule: "query",
|
||||
message: "All active queries we can run",
|
||||
data: queries,
|
||||
status: 200,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user