test(datamart): more data mart work

This commit is contained in:
2025-12-31 15:14:54 -06:00
parent 04fe1f1bfe
commit 4e6d35bc67
4 changed files with 51 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
/**
* each endpoint will be something like
* /api/datamart/{name}?{options}
* /api/datamart/{name}?{criteria}
*
* when getting the current queries we will need to map through the available queries we currently have and send back.
* example
@@ -8,7 +8,7 @@
* "name": "getopenorders",
* "endpoint": "/api/datamart/getopenorders",
* "description": "Returns open orders based on day count sent over, sDay 15 days in the past eDay 5 days in the future, can be left empty for this default days",
* "criteria": "sDay,eDay"
* "options": "sDay,eDay"
* },
*
* when a criteria is password over we will handle it by counting how many were passed up to 3 then deal with each one respectively

View File

@@ -1,18 +1,54 @@
import { Router } from "express";
import z from "zod";
import type { NewDatamart } from "../db/schema/datamart.schema.js";
import { apiReturn } from "../utils/returnHelper.utils.js";
const r = Router();
r.post("/add", async (_, res) => {
apiReturn(res, {
success: true,
level: "info",
module: "routes",
subModule: "prodSql",
message: "connect.message",
data: [{ connect: "" }],
status: 200,
});
const newQuery = z.object({
name: z.string().min(5),
description: z.string().min(30),
query: z.string().min(10),
options: z
.string()
.describe("This should be a set of keys separated by a comma")
.optional(),
});
r.post("/add", async (req, res) => {
try {
const v = newQuery.parse(req.body);
const query: NewDatamart = { ...v };
} catch (err) {
if (err instanceof z.ZodError) {
const flattened = z.flattenError(err);
// return res.status(400).json({
// error: "Validation failed",
// details: flattened,
// });
return apiReturn(res, {
success: false,
level: "error", //connect.success ? "info" : "error",
module: "routes",
subModule: "auth",
message: "Validation failed",
data: [flattened.fieldErrors],
status: 400, //connect.success ? 200 : 400,
});
}
return apiReturn(res, {
success: true,
level: "info",
module: "routes",
subModule: "prodSql",
message: "connect.message",
data: [{ connect: "" }],
status: 200,
});
}
});
export default r;