feat(lstv2 move): moved lstv2 into this app to keep them combined and easier to maintain
This commit is contained in:
39
lstV2/server/services/ocp/controller/lots/lots.ts
Normal file
39
lstV2/server/services/ocp/controller/lots/lots.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { lotQuery } from "../../../sqlServer/querys/ocp/lots.js";
|
||||
|
||||
type LotInfo = {
|
||||
success: boolean;
|
||||
message: string;
|
||||
data: any[];
|
||||
};
|
||||
export const getLots = async () => {
|
||||
const { data: l, error: lotError } = await tryCatch(
|
||||
query(lotQuery, "Alplalabel online lots")
|
||||
);
|
||||
|
||||
const lotInfo = l as LotInfo;
|
||||
|
||||
if (lotError) {
|
||||
console.log("lot error", lotError);
|
||||
return {
|
||||
success: false,
|
||||
message: "There was an error getting the lots",
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (lotInfo.success) {
|
||||
return {
|
||||
success: true,
|
||||
message: "Current active lots that are technically released.",
|
||||
data: lotInfo.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
success: true,
|
||||
message: `Error getting lot info due to: ${lotInfo.message}.`,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user