test(datamart): more work on datamart setup
This commit is contained in:
32
.env-example
Normal file
32
.env-example
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Server
|
||||||
|
PORT=3000
|
||||||
|
URL=http://localhost:3000
|
||||||
|
|
||||||
|
# authentication
|
||||||
|
BETTER_AUTH_SECRET=""
|
||||||
|
RESET_EXPIRY_SECONDS=3600
|
||||||
|
|
||||||
|
# logging
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
# prodServer
|
||||||
|
PROD_SERVER=usmcd1vms036
|
||||||
|
PROD_PLANT_TOKEN=test3
|
||||||
|
PROD_USER=alplaprod
|
||||||
|
PROD_PASSWORD=password
|
||||||
|
|
||||||
|
# postgres connection
|
||||||
|
DATABASE_HOST=localhost
|
||||||
|
DATABASE_PORT=5433
|
||||||
|
DATABASE_USER=user
|
||||||
|
DATABASE_PASSWORD=password
|
||||||
|
DATABASE_DB=lst_dev
|
||||||
|
|
||||||
|
# how is the app running server or client when in client mode you must provide the server
|
||||||
|
APP_RUNNING_IN=server
|
||||||
|
SERVER_NAME=localhost
|
||||||
|
|
||||||
|
#dev stuff
|
||||||
|
GITEA_TOKEN=""
|
||||||
|
EMAIL_USER=""
|
||||||
|
EMAIL_PASSWORD=""
|
||||||
@@ -1,7 +1,32 @@
|
|||||||
|
import { eq } from "drizzle-orm";
|
||||||
import type { Express } from "express";
|
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";
|
import runQuery from "./getDatamart.route.js";
|
||||||
|
|
||||||
export const setupDatamartRoutes = (baseUrl: string, app: Express) => {
|
export const setupDatamartRoutes = (baseUrl: string, app: Express) => {
|
||||||
//setup all the routes
|
//setup all the routes
|
||||||
|
|
||||||
app.use(`${baseUrl}/api/datamart`, runQuery);
|
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,
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const newQuery = z.object({
|
|||||||
.optional(),
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
r.post("/add", async (req, res) => {
|
r.post("/", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const v = newQuery.parse(req.body);
|
const v = newQuery.parse(req.body);
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ r.post("/add", async (req, res) => {
|
|||||||
module: "routes",
|
module: "routes",
|
||||||
subModule: "auth",
|
subModule: "auth",
|
||||||
message: "Validation failed",
|
message: "Validation failed",
|
||||||
data: [flattened.fieldErrors],
|
data: [flattened],
|
||||||
status: 400, //connect.success ? 200 : 400,
|
status: 400, //connect.success ? 200 : 400,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -46,8 +46,8 @@ r.post("/add", async (req, res) => {
|
|||||||
level: "error",
|
level: "error",
|
||||||
module: "routes",
|
module: "routes",
|
||||||
subModule: "datamart",
|
subModule: "datamart",
|
||||||
message: "connect.message",
|
message: "There was an error creating the new query",
|
||||||
data: [{ connect: "" }],
|
data: [err],
|
||||||
status: 200,
|
status: 200,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ r.get("/:name", async (req, res) => {
|
|||||||
).toString();
|
).toString();
|
||||||
|
|
||||||
const dataRan = await runDatamartQuery({ name, criteria });
|
const dataRan = await runDatamartQuery({ name, criteria });
|
||||||
apiReturn(res, {
|
return apiReturn(res, {
|
||||||
success: dataRan.success,
|
success: dataRan.success,
|
||||||
level: "info",
|
level: "info",
|
||||||
module: "datamart",
|
module: "datamart",
|
||||||
|
|||||||
Reference in New Issue
Block a user