Version based API - Pushed here before the 5000 and 8000

This commit is contained in:
2025-06-21 15:16:52 +05:30
parent dead851b1a
commit 3ec45276f4
114 changed files with 7547 additions and 1436 deletions

View File

@@ -23,7 +23,7 @@ USER appuser
COPY . .
# Expose the port that the application listens on.
EXPOSE 4999
EXPOSE 3503
# Run the application.

View File

@@ -1,6 +1,7 @@
import { Request, Response } from "express";
import {
AuthLogin,
AuthLogins,
AuthLogout,
AuthSignup,
forgetPassword,
@@ -12,7 +13,6 @@ export const SignupController = async (
): Promise<void> => {
try {
const { userName, Email, Password } = req.body;
console.log('req.body: ', req.body);
if (!userName || !Email || !Password) {
res.status(400).json({
message: "All fields are required",
@@ -20,7 +20,6 @@ export const SignupController = async (
return;
}
const result = await AuthSignup(req.body);
console.log('result: ', result);
switch (result.status) {
case "User already exists":
@@ -78,7 +77,6 @@ export const SignInController = async (
ForceLogoutData: result.data,
});
break;
case "User_Datas not found":
res.status(404).json({
message: "User_Datas not found",
@@ -245,3 +243,69 @@ export const ResetPasswordController = async (
return;
}
};
// export const SignInController = async (
// req: Request,
// res: Response
// ): Promise<void> => {
// try {
// const { Email, Password, fingerprint } = req.body;
// if (!fingerprint || !Email || !Password) {
// res.status(400).json({
// message: "All fields are required",
// });
// return;
// }
// const result = await AuthLogins(req.body);
// switch (result.status) {
// case "User Not Found!!! Kindly signup...":
// res.status(404).json({
// message: "User Not Found!!! Kindly signup...",
// });
// break;
// case "Email & Password is invalid...Check the credentials":
// res.status(400).json({
// message: "Email & Password is invalid...Check the credentials",
// });
// break;
// // case "Already LoggedIn on another browser....Please logout!!!":
// // res.status(403).json({
// // message: "Already LoggedIn on another browser....Please logout!!!",
// // ForceLogoutData: result.data,
// // });
// // break;
// case "Already LoggedIn on another browser....ForceLogout Implemented!!!":
// res.status(200).json({
// message: result.data
// });
// break;
// case "User_Datas not found":
// res.status(404).json({
// message: "User_Datas not found",
// });
// break;
// case "User update failed.":
// res.status(400).json({
// message: "User update failed.",
// });
// break;
// case "Success":
// res.status(200).json({
// message: result.data,
// });
// break;
// default:
// res.status(500).json({
// message: "Internal server error",
// });
// break;
// }
// } catch (error) {
// res.status(500).json({
// message: "An unexpected error occurred",
// });
// return;
// }
// };

View File

@@ -12,8 +12,8 @@ export const UpsertAisleController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { aisleUuid, points, type, projectId } = req.body;
if (!organization || !userId || !aisleUuid || !projectId) {
const { aisleUuid, points, type, projectId, versionId } = req.body;
if (!organization || !userId || !aisleUuid || !projectId || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -24,6 +24,7 @@ export const UpsertAisleController = async (
type,
aisleUuid,
projectId,
versionId,
organization,
userId,
};
@@ -39,6 +40,11 @@ export const UpsertAisleController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Aisle Not Updated":
res.status(200).json({
message: "Aisle Not Updated",
@@ -83,8 +89,8 @@ export const DeleteAisleController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { aisleUuid, projectId } = req.body;
if (!organization || !userId || !aisleUuid || !projectId) {
const { aisleUuid, projectId, versionId } = req.body;
if (!organization || !userId || !aisleUuid || !projectId || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -95,6 +101,7 @@ export const DeleteAisleController = async (
projectId,
organization,
userId,
versionId,
};
const result = await DeleteAisle(data);
switch (result.status) {
@@ -108,6 +115,11 @@ export const DeleteAisleController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Aisle not found":
res.status(200).json({
message: "Aisle not found",
@@ -136,7 +148,7 @@ export const AllAisleController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId } = req.params;
const { projectId, versionId } = req.params;
if (!organization || !userId || !projectId) {
res.status(400).json({
message: "All fields are required",
@@ -145,6 +157,7 @@ export const AllAisleController = async (
}
const data = {
projectId,
versionId,
organization,
userId,
};
@@ -160,6 +173,11 @@ export const AllAisleController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Aisle not found":
res.status(200).json(result.data);
break;

View File

@@ -15,8 +15,16 @@ export const NewLineController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { line, type, layer, projectId } = req.body;
if (!organization || !userId || !line || !type || !layer || !projectId) {
const { line, type, layer, projectId, versionId } = req.body;
if (
!organization ||
!userId ||
!line ||
!type ||
!layer ||
!projectId ||
!versionId
) {
res.status(400).json({
message: "All fields are required",
});
@@ -28,6 +36,7 @@ export const NewLineController = async (
layer,
projectId,
organization,
versionId,
userId,
};
const result = await CreateLineItems(data);
@@ -43,6 +52,11 @@ export const NewLineController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Success":
res.status(201).json(result.data);
break;
@@ -64,8 +78,15 @@ export const UpdateLineController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { uuid, position, projectId } = req.body;
if (!organization || !userId || !uuid || !position || projectId) {
const { uuid, position, projectId, versionId } = req.body;
if (
!organization ||
!userId ||
!uuid ||
!position ||
projectId ||
!versionId
) {
res.status(400).json({
message: "All fields are required",
});
@@ -74,6 +95,7 @@ export const UpdateLineController = async (
const result = await UpdateLineItems({
organization,
projectId,
versionId,
uuid,
position,
userId,
@@ -90,8 +112,13 @@ export const UpdateLineController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Success":
res.status(201).json(result.data);
res.status(200).json(result.data);
break;
default:
res.status(500).json({
@@ -111,8 +138,8 @@ export const DeleteLineController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId, line } = req.body;
if (!organization || !userId || !projectId || !line) {
const { projectId, line, versionId } = req.body;
if (!organization || !userId || !projectId || !line || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -121,6 +148,7 @@ export const DeleteLineController = async (
const result = await DeleteLineItems({
organization,
projectId,
versionId,
line,
userId,
});
@@ -136,6 +164,11 @@ export const DeleteLineController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "line not found":
res.status(404).json({
message: "data not found",
@@ -162,8 +195,8 @@ export const DeleteLayerController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId, layer } = req.body;
if (!organization || !userId || !projectId || !layer) {
const { projectId, layer, versionId } = req.body;
if (!organization || !userId || !projectId || !layer || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -172,6 +205,7 @@ export const DeleteLayerController = async (
const result = await DeleteLayer({
organization,
projectId,
versionId,
layer,
userId,
});
@@ -187,6 +221,11 @@ export const DeleteLayerController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "layer not found":
res.status(404).json({
message: "data not found",
@@ -214,8 +253,8 @@ export const DeleteLinePointsController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId, uuid } = req.body;
if (!organization || !userId || !projectId || !uuid) {
const { projectId, uuid, versionId } = req.body;
if (!organization || !userId || !projectId || !uuid || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -223,6 +262,7 @@ export const DeleteLinePointsController = async (
}
const result = await DeleteLinePoints({
organization,
versionId,
projectId,
uuid,
userId,
@@ -239,6 +279,11 @@ export const DeleteLinePointsController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Line not found":
res.status(404).json({
message: "data not found",
@@ -265,7 +310,7 @@ export const GetLinesController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId } = req.params;
const {versionId, projectId } = req.params;
if (!organization || !userId || !projectId) {
res.status(400).json({
message: "All fields are required",
@@ -274,7 +319,7 @@ export const GetLinesController = async (
}
const result = await GetLinesService({
organization,
projectId,
projectId,versionId,
userId,
});
@@ -289,6 +334,11 @@ export const GetLinesController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Line not found":
res.status(200).json(result.data);
break;

View File

@@ -25,13 +25,9 @@ export const CreateAssetController = async (
isLocked,
isVisible,
projectId,
versionId,
} = req.body;
if (
!organization ||
!userId ||
!projectId ||
!modelUuid
) {
if (!organization || !userId || !projectId || !modelUuid || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -49,6 +45,7 @@ export const CreateAssetController = async (
isLocked,
isVisible,
projectId,
versionId,
};
const result = await setAssetModel(data);
@@ -63,6 +60,11 @@ export const CreateAssetController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Updated successfully":
res.status(200).json(result.data);
break;
@@ -89,8 +91,15 @@ export const DeleteAssetController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { modelUuid, modelName, projectId } = req.body;
if (!organization || !userId || !modelUuid || !projectId || !modelName) {
const { modelUuid, modelName, projectId, versionId } = req.body;
if (
!organization ||
!userId ||
!modelUuid ||
!projectId ||
!modelName ||
!versionId
) {
res.status(400).json({
message: "All fields are required",
});
@@ -101,6 +110,7 @@ export const DeleteAssetController = async (
modelName,
modelUuid,
projectId,
versionId,
userId,
});
@@ -115,6 +125,11 @@ export const DeleteAssetController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "model not found":
res.status(404).json({
message: "Model not found",
@@ -148,7 +163,7 @@ export const GetAssetController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId } = req.params;
const { projectId,versionId } = req.params;
if (!organization || !userId || !projectId) {
res.status(400).json({
message: "All fields are required",
@@ -158,7 +173,7 @@ export const GetAssetController = async (
const result = await getFloorItems({
organization,
projectId,
userId,
userId,versionId,
});
switch (result.status) {
@@ -172,6 +187,11 @@ export const GetAssetController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "floorItems not found":
res.status(200).json([]);
break;
@@ -196,8 +216,15 @@ export const ReplaceEventDataController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { modelUuid, eventData, projectId } = req.body;
if (!organization || !userId || !projectId || !modelUuid || !eventData) {
const { modelUuid, eventData, projectId, versionId } = req.body;
if (
!organization ||
!userId ||
!projectId ||
!modelUuid ||
!versionId ||
!eventData
) {
res.status(400).json({
message: "All fields are required",
});
@@ -207,6 +234,7 @@ export const ReplaceEventDataController = async (
modelUuid,
organization,
eventData,
versionId,
projectId,
userId,
});
@@ -222,6 +250,11 @@ export const ReplaceEventDataController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Model not for this UUID":
res.status(404).json({
message: "Model not for this UUID",
@@ -256,6 +289,7 @@ export const AssetUpdatePosRotController = async (
isLocked,
isVisible,
projectId,
versionId,
} = req.body;
if (
!organization ||
@@ -266,6 +300,7 @@ export const AssetUpdatePosRotController = async (
!rotation ||
!modelName ||
!projectId ||
!versionId ||
!modelUuid
) {
res.status(400).json({
@@ -283,6 +318,7 @@ export const AssetUpdatePosRotController = async (
isLocked,
isVisible,
projectId,
versionId,
});
switch (result.status) {
@@ -296,6 +332,11 @@ export const AssetUpdatePosRotController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Asset not found":
res.status(404).json({
message: "Asset not found",

View File

@@ -13,13 +13,14 @@ export const SetNewCamera = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { position, target, rotation, projectId } = req.body;
const { position, target, rotation, projectId,versionId } = req.body;
if (
!organization ||
!userId ||
!position ||
!target ||
!rotation ||
!versionId ||
!projectId
) {
res.status(400).json({
@@ -32,7 +33,7 @@ export const SetNewCamera = async (
target,
rotation,
projectId,
organization,
organization,versionId,
userId,
};
const result = await SetCamera(data);
@@ -48,7 +49,11 @@ export const SetNewCamera = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Update Success":
res.status(200).json(result.data);
break;

View File

@@ -16,27 +16,16 @@ export const WallSetup = async (
modelUuid,
modelName,
position,
type,
assetId,
type,
csgposition,
csgscale,
quaternion,
scale,
projectId,
versionId,
} = req.body;
if (
!modelUuid ||
!modelName ||
!position ||
!type ||
!projectId ||
!csgscale ||
!csgposition ||
!quaternion ||
!scale ||
!organization ||
!userId
) {
if (!modelUuid || !organization || !userId || !projectId || !versionId) {
res.status(400).json({
message: "All fields are required!",
});
@@ -44,17 +33,18 @@ export const WallSetup = async (
}
const result = await setWallItems({
projectId,
versionId,
modelUuid,
modelName,
position,
type,
assetId,
csgposition,
csgscale,
quaternion,
scale,
organization,
userId,
assetId,
});
switch (result.status) {
case "User not found":
@@ -67,10 +57,15 @@ export const WallSetup = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Updated successfully":
res.status(200).json(result.data);
break;
case "wall Item created successfully":
case "Success":
res.status(201).json(result.data);
break;
default:
@@ -90,7 +85,7 @@ export const WallGet = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId } = req.params;
const { versionId, projectId } = req.params;
if (!organization || !userId || !projectId) {
res.status(400).json({
message: "All fields are required",
@@ -101,6 +96,7 @@ export const WallGet = async (
organization,
userId,
projectId,
versionId,
});
switch (result.status) {
@@ -114,6 +110,11 @@ export const WallGet = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "wallitems not found":
res.status(200).json(result.data);
break;
@@ -138,8 +139,15 @@ export const WallDelete = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId, modelName, modelUuid } = req.body;
if (!organization || !userId || !projectId || !modelName || !modelUuid) {
const { projectId, versionId, modelName, modelUuid } = req.body;
if (
!organization ||
!userId ||
!projectId ||
!modelName ||
!versionId ||
!modelUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -149,6 +157,7 @@ export const WallDelete = async (
organization,
userId,
projectId,
versionId,
modelName,
modelUuid,
});
@@ -164,6 +173,11 @@ export const WallDelete = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "model not found":
res.status(404).json({
message: "model not found",

View File

@@ -15,8 +15,8 @@ export const CreateZoneController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { zoneData, projectId } = req.body;
if (!organization || !userId || !zoneData || !projectId) {
const { zoneData, projectId, versionId } = req.body;
if (!organization || !userId || !zoneData || !projectId || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -25,6 +25,7 @@ export const CreateZoneController = async (
const data = {
zoneData,
projectId,
versionId,
organization,
userId,
};
@@ -41,6 +42,11 @@ export const CreateZoneController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "zone updated":
res.status(200).json({
message: "zone updated",
@@ -71,8 +77,8 @@ export const DeleteZoneController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { zoneUuid, projectId } = req.body;
if (!organization || !userId || !zoneUuid || !projectId) {
const { zoneUuid, projectId, versionId } = req.body;
if (!organization || !userId || !zoneUuid || !projectId || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -82,6 +88,7 @@ export const DeleteZoneController = async (
organization,
zoneUuid,
projectId,
versionId,
userId,
});
@@ -96,6 +103,11 @@ export const DeleteZoneController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Invalid zone ID":
res.status(404).json({
message: "Zone not found for the UUID",
@@ -124,7 +136,7 @@ export const GetZoneController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId } = req.params;
const { projectId, versionId } = req.params;
if (!organization || !userId || !projectId) {
res.status(400).json({
message: "All fields are required",
@@ -135,6 +147,7 @@ export const GetZoneController = async (
organization,
projectId,
userId,
versionId,
});
switch (result.status) {
@@ -148,6 +161,11 @@ export const GetZoneController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Invalid zone":
res.status(404).json({
message: "Zone not found for the UUID",
@@ -174,7 +192,7 @@ export const VizZoneController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId } = req.params;
const { projectId, versionId } = req.params;
if (!organization || !userId || !projectId) {
res.status(400).json({
message: "All fields are required",
@@ -184,6 +202,7 @@ export const VizZoneController = async (
const result = await VizZoneDatas({
organization,
projectId,
versionId,
userId,
});
@@ -198,6 +217,11 @@ export const VizZoneController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the UUID":
res.status(200).json(result.data);
break;
@@ -223,7 +247,7 @@ export const ZoneDataController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId, zoneUuid } = req.params;
const { projectId, zoneUuid, versionId } = req.params;
if (!organization || !userId || !projectId || !zoneUuid) {
res.status(400).json({
message: "All fields are required",
@@ -234,6 +258,7 @@ export const ZoneDataController = async (
organization,
projectId,
userId,
versionId,
zoneUuid,
});
@@ -248,6 +273,11 @@ export const ZoneDataController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",
@@ -274,7 +304,7 @@ export const SingleZonePanelController = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { projectId, zoneUuid } = req.params;
const { versionId, projectId, zoneUuid } = req.params;
if (!organization || !userId || !projectId || !zoneUuid) {
res.status(400).json({
message: "All fields are required",
@@ -285,6 +315,7 @@ export const SingleZonePanelController = async (
organization,
projectId,
userId,
versionId,
zoneUuid,
});
@@ -299,6 +330,11 @@ export const SingleZonePanelController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the UUID":
res.status(404).json({
message: "Zone not found for the UUID",

View File

@@ -0,0 +1,396 @@
import { Response } from "express";
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
import {
AllProductDatas,
EventDataDelete,
getProductDatas,
productAdd,
productDataDelete,
productRename,
} from "../../../../shared/services/simulation/productService.ts";
import { productAdddummy } from "../../../../shared/services/dummyservice.ts";
export const AddProductControllerdumy = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productUuid, eventDatas, projectId, productName } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (
!productUuid ||
!productName ||
!projectId ||
!userId ||
!organization
) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await productAdddummy({
productName,
productUuid,
eventDatas,
projectId,
userId,
organization,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "EventData updated successfully":
res.status(200).json({
message: "EventData updated successfully",
});
break;
case "EventData add successfully":
res.status(200).json({
message: "EventData add successfully",
});
break;
case "Success":
res.status(201).json({
message: "Product created Successfully",
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
return;
}
};
export const GetProductEventDatas = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productUuid, projectId } = req.query as {
productUuid: string;
projectId: string;
};
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!productUuid || !projectId || !userId || !organization) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await getProductDatas({
productUuid,
projectId,
userId,
organization,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "Product not found":
res.status(404).json({
message: "Product not found",
});
break;
case "Events not found":
res.status(200).json(result.data);
break;
case "Success":
res.status(200).json(result.data);
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
return;
}
};
export const DeleteProductController = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productUuid, projectId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!productUuid || !projectId || !userId || !organization) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await productDataDelete({
productUuid,
projectId,
userId,
organization,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "Product not found":
res.status(404).json({
message: "Product not found",
});
break;
case "Success":
res.status(200).json({
message: "Product Deleted Successfully",
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
return;
}
};
export const DeleteEventsController = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productUuid, projectId, modelUuid } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!productUuid || !projectId || !userId || !organization || !modelUuid) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await EventDataDelete({
productUuid,
modelUuid,
projectId,
userId,
organization,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "Product not found":
res.status(404).json({
message: "Product not found",
});
break;
case "Event Delete Unsuccessful":
res.status(200).json({
message: "Event Delete Unsuccessful",
});
break;
case "Success":
res.status(200).json({
message: "Events Deleted Successfully",
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
return;
}
};
export const ProjectBasedProductsController = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId } = req.params;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!projectId || !userId || !organization) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await AllProductDatas({
projectId,
userId,
organization,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "No products found":
res.status(200).json(result.data);
break;
case "Success":
res.status(200).json(result.data);
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
return;
}
};
export const RenameProductController = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productName, productUuid, projectId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (
!projectId ||
!userId ||
!organization ||
!productName ||
!productUuid
) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await productRename({
projectId,
productName,
productUuid,
userId,
organization,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "Product not found":
res.status(404).json({ message: "Product not found" });
break;
case "Rename Unsuccessful":
res.status(200).json({ message: "Product Rename Not Updated" });
break;
case "Success":
res.status(200).json({ message: "Product Rename Successfull" });
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
return;
}
};

View File

@@ -15,7 +15,8 @@ export const AddProductController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productUuid, eventDatas, projectId, productName } = req.body;
const { productUuid, eventDatas, projectId, versionId, productName } =
req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
@@ -25,6 +26,7 @@ export const AddProductController = async (
!productUuid ||
!productName ||
!projectId ||
!versionId ||
!userId ||
!organization
) {
@@ -38,6 +40,7 @@ export const AddProductController = async (
productUuid,
eventDatas,
projectId,
versionId,
userId,
organization,
});
@@ -88,9 +91,10 @@ export const GetProductEventDatas = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productUuid, projectId } = req.query as {
const { productUuid, projectId, versionId } = req.query as {
productUuid: string;
projectId: string;
versionId: string;
};
if (!req.user?.userId || !req.user?.organization) {
@@ -105,6 +109,7 @@ export const GetProductEventDatas = async (
}
const result = await getProductDatas({
productUuid,
versionId,
projectId,
userId,
organization,
@@ -116,6 +121,11 @@ export const GetProductEventDatas = async (
message: "User not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Project not found":
res.status(404).json({
@@ -152,13 +162,13 @@ export const DeleteProductController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productUuid, projectId } = req.body;
const { productUuid, projectId, versionId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!productUuid || !projectId || !userId || !organization) {
if (!productUuid || !projectId || !versionId || !userId || !organization) {
res.status(400).json({
message: "All fields are required",
});
@@ -167,6 +177,7 @@ export const DeleteProductController = async (
const result = await productDataDelete({
productUuid,
projectId,
versionId,
userId,
organization,
});
@@ -212,13 +223,20 @@ export const DeleteEventsController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productUuid, projectId, modelUuid } = req.body;
const { productUuid, projectId, modelUuid, versionId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!productUuid || !projectId || !userId || !organization || !modelUuid) {
if (
!productUuid ||
!projectId ||
!versionId ||
!userId ||
!organization ||
!modelUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -228,6 +246,7 @@ export const DeleteEventsController = async (
productUuid,
modelUuid,
projectId,
versionId,
userId,
organization,
});
@@ -278,7 +297,7 @@ export const ProjectBasedProductsController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId } = req.params;
const { projectId, versionId } = req.params;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
@@ -293,6 +312,7 @@ export const ProjectBasedProductsController = async (
const result = await AllProductDatas({
projectId,
userId,
versionId,
organization,
});
@@ -308,6 +328,11 @@ export const ProjectBasedProductsController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "No products found":
res.status(200).json(result.data);
break;
@@ -333,7 +358,7 @@ export const RenameProductController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { productName, productUuid, projectId } = req.body;
const { productName, productUuid, projectId, versionId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
@@ -341,6 +366,7 @@ export const RenameProductController = async (
}
if (
!projectId ||
!versionId ||
!userId ||
!organization ||
!productName ||
@@ -353,6 +379,7 @@ export const RenameProductController = async (
}
const result = await productRename({
projectId,
versionId,
productName,
productUuid,
userId,

View File

@@ -0,0 +1,346 @@
import { Response } from "express";
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
import {
addComments,
createThread,
deleteComments,
deleteThread,
findThreads,
updateThreadTitle,
} from "../../../../shared/services/Thread/ThreadService.ts";
export const threadCreate = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!projectId || !organization || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await createThread({ ...req.body, userId, organization });
switch (result?.status) {
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "CurrentVersion Data not found":
res.status(404).json({
message: "CurrentVersion Data not found",
});
break;
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Success":
res.status(201).json({
message: "Thread created Successfully",
threadData: result.data,
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};
export const threaddelete = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!projectId || !organization || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await deleteThread({ ...req.body, userId, organization });
switch (result?.status) {
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "CurrentVersion Data not found":
res.status(404).json({
message: "CurrentVersion Data not found",
});
break;
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Success":
res.status(201).json({
message: "Thread deleted Successfully",
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};
export const threadUpdateTitle = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId, threadId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!projectId || !threadId || !organization || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await updateThreadTitle({
...req.body,
userId,
organization,
});
switch (result?.status) {
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "CurrentVersion Data not found":
res.status(404).json({
message: "CurrentVersion Data not found",
});
break;
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Success":
res.status(201).json({
message: "ThreadTitle updated Successfully",
data: result.data,
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};
export const threadComment = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId, threadId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!projectId || !threadId || !organization || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await addComments({ ...req.body, userId, organization });
console.log("result: ", result);
switch (result?.status) {
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "CurrentVersion Data not found":
res.status(404).json({
message: "CurrentVersion Data not found",
});
break;
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "updated":
res.status(200).json({
message: "Comment updated successfully",
data: result.data,
});
break;
case "Success":
res.status(201).json({
message: "Thread comments add Successfully",
data: result.data,
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};
export const threadCommentDelete = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId, threadId, commentId } = req.body;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!projectId || !commentId || !threadId || !organization || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await deleteComments({ ...req.body, userId, organization });
switch (result?.status) {
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "CurrentVersion Data not found":
res.status(404).json({
message: "CurrentVersion Data not found",
});
break;
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "thread not found":
res.status(404).json({
message: "thread not found",
});
break;
case "unauthorized":
res.status(404).json({
message: "You can only delete your own comment.",
});
break;
case "Success":
res.status(201).json({
message: "Thread comment deleted Successfully",
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};
export const getALLthreads = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId } = req.params;
if (!req.user?.userId || !req.user?.organization) {
res.status(401).json({ message: "Unauthorized" });
return;
}
if (!projectId || !organization || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await findThreads({ projectId, userId, organization });
switch (result?.status) {
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "CurrentVersion Data not found":
res.status(404).json({
message: "CurrentVersion Data not found",
});
break;
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Success":
res.status(201).json({
data: result.data,
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};

View File

@@ -1,24 +1,224 @@
import { Request, Response } from "express";
import versionService from "../../../../shared/services/version/versionService.ts";
import {
CreateVersion,
GetVersionById,
RollBackversion,
VersionHistory,
} from "../../../../shared/services/version/versionService.ts";
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
export const versioncontroller = async (
req: Request,
export const versionAddcontroller = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { projectId, userId, description, db } = req.body;
const { organization, role, userId } = req.user || {};
if (!organization || !role || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const { projectId, versionName, hierarchyVersion, description, createdBy } =
req.body;
const result = await versionService.saveCurrentStateAsVersion(
db,
const result = await CreateVersion({
organization,
hierarchyVersion,
createdBy,
versionName,
projectId,
userId,
description
);
description,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "Parent Version not found":
res.status(404).json({
message: "Parent Version not found",
});
break;
case "Success":
res.status(200).json(result.data);
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "An unexpected error occurred",
message: "Unknown error",
});
}
};
export const GetversionList = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { organization, role, userId } = req.user || {};
if (!organization || !role || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const { projectId, versionId } = req.params;
const result = await GetVersionById({
organization,
projectId,
versionId,
userId,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "Version not found for the project":
res.status(200).json([]);
break;
case "Success":
res.status(200).json({
versionDatas: result.data,
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};
export const rollbackcontroller = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { organization, role, userId } = req.user || {};
if (!organization || !role || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const { versionId, projectId } = req.body;
const result = await RollBackversion({
organization,
versionId,
projectId,
userId,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "Mentioned Version not found for the Rollback":
res.status(404).json({
message: "Mentioned Version not found for the Rollback",
});
break;
case "Success":
res.status(200).json({
message: "Rollback successfull",
versionId: result.data,
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};
export const GetversionHistory = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { organization, role, userId } = req.user || {};
if (!organization || !role || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const { projectId } = req.params;
const page = parseInt(req.query.page as string) || 1;
const limit = parseInt(req.query.limit as string) || 10;
const result = await VersionHistory({
organization,
page,
limit,
projectId,
userId,
});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Project not found":
res.status(404).json({
message: "Project not found",
});
break;
case "Versions not found":
res.status(200).json([]);
break;
case "Success":
res.status(200).json(result.data);
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
return;
}
};

View File

@@ -14,13 +14,13 @@ export const FloatAddController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { widget, zoneUuid, index, projectId } = req.body;
const { widget, zoneUuid, index, projectId, versionId } = req.body;
if (
!userId ||
!organization ||
!widget ||
!zoneUuid ||
!index ||
!versionId ||
!projectId
) {
res.status(400).json({
@@ -30,6 +30,7 @@ export const FloatAddController = async (
}
const result = await AddFloat({
organization,
versionId,
widget,
zoneUuid,
index,
@@ -48,6 +49,11 @@ export const FloatAddController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the zoneUuid":
res.status(404).json({
message: "Zone not found for the zoneUuid",
@@ -87,8 +93,15 @@ export const DeleteFloatController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { floatWidgetID, projectId, zoneUuid } = req.body;
if (!userId || !organization || !floatWidgetID || !projectId || !zoneUuid) {
const { floatWidgetID, projectId, zoneUuid, versionId } = req.body;
if (
!userId ||
!organization ||
!floatWidgetID ||
!projectId ||
!versionId ||
!zoneUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -98,6 +111,7 @@ export const DeleteFloatController = async (
organization,
floatWidgetID,
zoneUuid,
versionId,
projectId,
userId,
});
@@ -112,6 +126,11 @@ export const DeleteFloatController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the zoneUuid":
res.status(404).json({
message: "Zone not found for the zoneUuid",
@@ -151,13 +170,14 @@ export const DuplicateFloatController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { widget, projectId, zoneUuid, index } = req.body;
const { widget, projectId, zoneUuid, index, versionId } = req.body;
if (
!userId ||
!organization ||
!widget ||
!projectId ||
!zoneUuid ||
!versionId ||
!index
) {
res.status(400).json({
@@ -169,6 +189,7 @@ export const DuplicateFloatController = async (
organization,
widget,
zoneUuid,
versionId,
index,
projectId,
userId,
@@ -184,6 +205,11 @@ export const DuplicateFloatController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the zoneUuid":
res.status(404).json({
message: "Zone not found for the zoneUuid",
@@ -228,7 +254,7 @@ export const GetFloatController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId, zoneUuid } = req.params;
const { projectId, zoneUuid,versionId } = req.params;
if (!userId || !organization || !projectId || !zoneUuid) {
res.status(400).json({
message: "All fields are required",
@@ -236,7 +262,7 @@ export const GetFloatController = async (
return;
}
const result = await GetFloatWidget({
organization,
organization,versionId,
zoneUuid,
projectId,
userId,
@@ -252,6 +278,11 @@ export const GetFloatController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",

View File

@@ -13,8 +13,15 @@ export const AddPanelController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { panelOrder, zoneUuid, projectId } = req.body;
if (!userId || !organization || !panelOrder || !zoneUuid || !projectId) {
const { panelOrder, zoneUuid, projectId, versionId } = req.body;
if (
!userId ||
!organization ||
!panelOrder ||
!versionId ||
!zoneUuid ||
!projectId
) {
res.status(400).json({
message: "All fields are required",
});
@@ -24,6 +31,7 @@ export const AddPanelController = async (
organization,
panelOrder,
zoneUuid,
versionId,
projectId,
userId,
});
@@ -39,6 +47,11 @@ export const AddPanelController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",
@@ -74,8 +87,15 @@ export const DeletePanelController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { panelName, projectId, zoneUuid } = req.body;
if (!userId || !organization || !panelName || !projectId || !zoneUuid) {
const { panelName, projectId, zoneUuid, versionId } = req.body;
if (
!userId ||
!organization ||
!panelName ||
!projectId ||
!versionId ||
!zoneUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -86,6 +106,7 @@ export const DeletePanelController = async (
panelName,
zoneUuid,
projectId,
versionId,
userId,
});
switch (result.status) {
@@ -99,6 +120,11 @@ export const DeletePanelController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",
@@ -133,8 +159,15 @@ export const ClearPanelController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { panelName, projectId, zoneUuid } = req.body;
if (!userId || !organization || !panelName || !projectId || !zoneUuid) {
const { panelName, projectId, zoneUuid, versionId } = req.body;
if (
!userId ||
!organization ||
!panelName ||
!versionId ||
!projectId ||
!zoneUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -145,6 +178,7 @@ export const ClearPanelController = async (
panelName,
zoneUuid,
projectId,
versionId,
userId,
});
switch (result.status) {
@@ -158,6 +192,11 @@ export const ClearPanelController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",
@@ -197,8 +236,15 @@ export const LockedPanelController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId, zoneUuid, lockedPanel } = req.body;
if (!userId || !organization || !projectId || !zoneUuid || !lockedPanel) {
const { projectId, zoneUuid, lockedPanel, versionId } = req.body;
if (
!userId ||
!organization ||
!projectId ||
!versionId ||
!zoneUuid ||
!lockedPanel
) {
res.status(400).json({
message: "All fields are required",
});
@@ -210,6 +256,7 @@ export const LockedPanelController = async (
lockedPanel,
userId,
projectId,
versionId,
});
switch (result.status) {
case "User not found":
@@ -222,6 +269,11 @@ export const LockedPanelController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",

View File

@@ -13,8 +13,8 @@ export const AddTemplateController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { template, projectId } = req.body;
if (!userId || !organization || !template || !projectId) {
const { template, projectId, versionId } = req.body;
if (!userId || !organization || !template || !projectId || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -25,6 +25,7 @@ export const AddTemplateController = async (
template,
projectId,
userId,
versionId,
});
switch (result.status) {
@@ -38,6 +39,11 @@ export const AddTemplateController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "TemplateID alreay exists":
res.status(200).json({
message: "TemplateID alreay exists",
@@ -72,8 +78,15 @@ export const AddTemToZoneController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { templateID, projectId, zoneUuid } = req.body;
if (!userId || !organization || !templateID || !projectId || !zoneUuid) {
const { templateID, projectId, zoneUuid, versionId } = req.body;
if (
!userId ||
!organization ||
!templateID ||
!versionId ||
!projectId ||
!zoneUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -85,6 +98,7 @@ export const AddTemToZoneController = async (
zoneUuid,
projectId,
userId,
versionId,
});
switch (result.status) {
case "User not found":
@@ -97,6 +111,11 @@ export const AddTemToZoneController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",
@@ -132,8 +151,8 @@ export const TemplateDeleteController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { templateID, projectId } = req.body;
if (!userId || !organization || !templateID || !projectId) {
const { templateID, projectId, versionId } = req.body;
if (!userId || !organization || !templateID || !projectId || !versionId) {
res.status(400).json({
message: "All fields are required",
});
@@ -144,6 +163,7 @@ export const TemplateDeleteController = async (
organization,
templateID,
projectId,
versionId,
});
switch (result.status) {
case "User not found":
@@ -156,6 +176,11 @@ export const TemplateDeleteController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Template not found":
res.status(404).json({
message: "Template not found",
@@ -190,7 +215,7 @@ export const GetTemplateController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId } = req.params;
const { projectId,versionId } = req.params;
if (!userId || !organization || !projectId) {
res.status(400).json({
message: "All fields are required",
@@ -199,7 +224,7 @@ export const GetTemplateController = async (
}
const result = await GetAllTemplates({
organization,
userId,
userId,versionId,
projectId,
});
switch (result.status) {
@@ -213,6 +238,11 @@ export const GetTemplateController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "All Datas":
res.status(404).json([]);
break;

View File

@@ -13,8 +13,15 @@ export const AddWidgetController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { widget, projectId, zoneUuid } = req.body;
if (!userId || !organization || !widget || !projectId || !zoneUuid) {
const { widget, projectId, zoneUuid, versionId } = req.body;
if (
!userId ||
!organization ||
!widget ||
!projectId ||
!versionId ||
!zoneUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -26,6 +33,7 @@ export const AddWidgetController = async (
projectId,
userId,
zoneUuid,
versionId,
});
switch (result.status) {
@@ -39,6 +47,11 @@ export const AddWidgetController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the zoneUuid":
res.status(404).json({
message: "Zone not found",
@@ -88,8 +101,15 @@ export const WidgetDeleteController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { widgetID, projectId, zoneUuid } = req.body;
if (!userId || !organization || !widgetID || !projectId || !zoneUuid) {
const { widgetID, projectId, zoneUuid, versionId } = req.body;
if (
!userId ||
!organization ||
!widgetID ||
!versionId ||
!projectId ||
!zoneUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -101,6 +121,7 @@ export const WidgetDeleteController = async (
zoneUuid,
projectId,
userId,
versionId,
});
switch (result.status) {
case "User not found":
@@ -113,6 +134,11 @@ export const WidgetDeleteController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the zoneUuid":
res.status(404).json({
message: "Zone not found for the zoneUuid",
@@ -147,13 +173,14 @@ export const WidgetUpdateController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { values, projectId, zoneUuid, widgetID } = req.body;
const { values, projectId, zoneUuid, widgetID, versionId } = req.body;
if (
!userId ||
!organization ||
!widgetID ||
!values ||
!projectId ||
!versionId ||
!zoneUuid
) {
res.status(400).json({
@@ -168,6 +195,7 @@ export const WidgetUpdateController = async (
widgetID,
projectId,
userId,
versionId,
});
switch (result.status) {
case "User not found":
@@ -180,6 +208,12 @@ export const WidgetUpdateController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the zoneUuid":
res.status(404).json({
message: "Zone not found for the zoneUuid",
@@ -214,8 +248,9 @@ export const GetWidgetController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId, zoneUuid, widgetID } = req.query as {
const { projectId, zoneUuid, widgetID, versionId } = req.query as {
projectId: string;
versionId: string;
zoneUuid: string;
widgetID: string;
};
@@ -230,6 +265,7 @@ export const GetWidgetController = async (
zoneUuid,
widgetID,
projectId,
versionId,
userId,
});
switch (result.status) {
@@ -243,6 +279,12 @@ export const GetWidgetController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the zoneUuid":
res.status(404).json({
message: "Zone not found for the zoneUuid",

View File

@@ -13,8 +13,15 @@ export const Add3dWidgetController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { widget, projectId, zoneUuid } = req.body;
if (!userId || !organization || !widget || !projectId || !zoneUuid) {
const { widget, projectId, zoneUuid, versionId } = req.body;
if (
!userId ||
!organization ||
!widget ||
!projectId ||
!versionId ||
!zoneUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -26,6 +33,7 @@ export const Add3dWidgetController = async (
userId,
zoneUuid,
projectId,
versionId,
});
switch (result.status) {
@@ -39,6 +47,11 @@ export const Add3dWidgetController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found for the zoneUuid":
res.status(200).json({
message: "Zone not found",
@@ -83,7 +96,7 @@ export const Update3DwidgetController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { id, position, rotation, projectId, zoneUuid } = req.body;
const { id, position, rotation, projectId, zoneUuid, versionId } = req.body;
if (
!userId ||
!organization ||
@@ -91,6 +104,7 @@ export const Update3DwidgetController = async (
!position ||
!rotation ||
!projectId ||
!versionId ||
!zoneUuid
) {
res.status(400).json({
@@ -106,6 +120,7 @@ export const Update3DwidgetController = async (
userId,
zoneUuid,
projectId,
versionId,
});
switch (result.status) {
case "User not found":
@@ -118,6 +133,11 @@ export const Update3DwidgetController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",
@@ -157,8 +177,15 @@ export const Delete3DwidgetController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { id, projectId, zoneUuid } = req.body;
if (!userId || !organization || !id || !projectId || !zoneUuid) {
const { id, projectId, zoneUuid, versionId } = req.body;
if (
!userId ||
!organization ||
!id ||
!projectId ||
!versionId ||
!zoneUuid
) {
res.status(400).json({
message: "All fields are required",
});
@@ -170,6 +197,7 @@ export const Delete3DwidgetController = async (
userId,
zoneUuid,
projectId,
versionId,
});
switch (result.status) {
case "User not found":
@@ -182,6 +210,11 @@ export const Delete3DwidgetController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",
@@ -221,7 +254,7 @@ export const Get3DWidgetController = async (
): Promise<void> => {
try {
const { userId, organization } = req.user || {};
const { projectId, zoneUuid } = req.params;
const { projectId, zoneUuid, versionId } = req.params;
if (!userId || !organization || !projectId) {
res.status(400).json({
message: "All fields are required",
@@ -232,6 +265,7 @@ export const Get3DWidgetController = async (
organization,
userId,
zoneUuid,
versionId,
projectId,
});
switch (result.status) {
@@ -245,6 +279,11 @@ export const Get3DWidgetController = async (
message: "Project not found",
});
break;
case "Version Data not found":
res.status(404).json({
message: "Version Data not found",
});
break;
case "Zone not found":
res.status(404).json({
message: "Zone not found",

View File

@@ -0,0 +1,93 @@
import { Response } from "express";
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
import { restoreSnapshotService } from "../../../../shared/services/yjs/snapshot.ts";
import { clearSnapshotController, restoreYDocFromAutoSave } from "../../../../shared/services/yjs/auto-save.ts";
export const autoSaveRestore = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { organization, versionId, projectId, } = req.body;
if (!organization || !versionId ) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await restoreYDocFromAutoSave({ organization, versionId,projectId });
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Snapshot not found":
res.status(404).json({
message: "Snapshot not found",
});
break;
case "Success":
res.status(200).json({
AutoSave: result,
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};
export const clearAutoSaveRestore = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { organization, versionId, projectId, } = req.body;
if (!organization || !versionId ) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await clearSnapshotController({ organization, versionId,projectId });
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Snapshot not found":
res.status(404).json({
message: "Snapshot not found",
});
break;
case "Success":
res.status(200).json({
message: "Snapshot autosave deleted",
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};

View File

@@ -0,0 +1,92 @@
import { Response } from "express";
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
import { listSnapshotService, restoreSnapshotService } from "../../../../shared/services/yjs/snapshot.ts";
export const SnapshotRestore = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { organization, snapshotId, userId,ydoc } = req.body;
if (!organization || !snapshotId ) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await restoreSnapshotService({ organization, snapshotId,ydoc });
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Snapshot not found":
res.status(404).json({
message: "Snapshot not found",
});
break;
case "Success":
res.status(200).json({
Snapshot: result,
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};
export const SnapshotList = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { projectId, versionId, organization } = req.body;
if (!organization || !versionId ) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await listSnapshotService({ projectId, versionId, organization});
switch (result.status) {
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "Snapshot not found":
res.status(404).json({
message: "Snapshot not found",
});
break;
case "Success":
res.status(200).json({
Snapshot: result,
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};

View File

@@ -10,6 +10,6 @@ const V1Aisle = express.Router();
V1Aisle.post("/UpsertAisle", tokenValidator, UpsertAisleController);
V1Aisle.patch("/DeleteAisle", tokenValidator, DeleteAisleController);
V1Aisle.get("/Aisles/:projectId", tokenValidator, AllAisleController);
V1Aisle.get("/Aisles/:projectId/:versionId", tokenValidator, AllAisleController);
export default V1Aisle;

View File

@@ -15,20 +15,20 @@ V1Zone.post("/zones", tokenValidator, CreateZoneController);
V1Zone.patch("/zones/delete", tokenValidator, DeleteZoneController);
V1Zone.get(
"/zones/visualization/:projectId",
"/zones/visualization/:projectId/:versionId",
tokenValidator,
VizZoneController
);
V1Zone.get(
"/zones/:projectId/:zoneUuid",
"/zones/:projectId/:zoneUuid/:versionId",
tokenValidator,
ZoneDataController
);
V1Zone.get(
"/zones/panel/:projectId/:zoneUuid",
"/zones/panel/:projectId/:zoneUuid/:versionId",
tokenValidator,
SingleZonePanelController
);
V1Zone.get("/zones/:projectId", tokenValidator, GetZoneController);
V1Zone.get("/zones/:projectId/:versionId", tokenValidator, GetZoneController);
export default V1Zone;

View File

@@ -20,7 +20,7 @@ V1Asset.patch(
AssetUpdatePosRotController
);
V1Asset.get(
"/floorAssets/:projectId",
"/floorAssets/:projectId/:versionId",
tokenValidator,
GetAssetController
);

View File

@@ -16,5 +16,5 @@ V1Line.post("/points", tokenValidator, UpdateLineController);
V1Line.patch("/layers/delete", tokenValidator, DeleteLayerController);
V1Line.patch("/lines/delete", tokenValidator, DeleteLineController);
V1Line.patch("/points/delete", tokenValidator, DeleteLinePointsController);
V1Line.get("/lines/:projectId", tokenValidator, GetLinesController);
V1Line.get("/lines/:projectId/:versionId", tokenValidator, GetLinesController);
export default V1Line;

View File

@@ -19,7 +19,7 @@ V1Wall.patch(
WallDelete
);
V1Wall.get(
"/walls/:projectId",
"/walls/:projectId/:versionId",
tokenValidator,
WallGet
);

View File

@@ -16,7 +16,7 @@ V1Product.get("/EventsByProduct", tokenValidator, GetProductEventDatas);
V1Product.patch("/DeleteEvent", tokenValidator, DeleteEventsController);
V1Product.patch("/DeleteProduct", tokenValidator, DeleteProductController);
V1Product.get(
"/ProjectProducts/:projectId",
"/ProjectProducts/:projectId/:versionId",
tokenValidator,
ProjectBasedProductsController
);

View File

@@ -6,7 +6,6 @@ import {
SignOutController,
SignupController,
} from "../v1Controllers/authController/authControllers.ts";
import { versioncontroller } from "../v1Controllers/versionController/versioncontroller.ts";
const Authrouter = express.Router();
Authrouter.post("/Auth/signup", SignupController);
@@ -14,6 +13,5 @@ Authrouter.post("/Auth/login", SignInController);
Authrouter.post("/Auth/logout", SignOutController);
Authrouter.post("/Auth/forgetPassword", ForgetPasswordController);
Authrouter.post("/Auth/reset-password/:resetToken", ResetPasswordController);
Authrouter.post("/Auth/versionData", versioncontroller);
export default Authrouter;

View File

@@ -0,0 +1,12 @@
import express from "express";
import { tokenValidator } from "../../../shared/utils/token.ts";
import { AddProductControllerdumy } from "../v1Controllers/dummycontroller.ts/productdummycontroller.ts";
const Dummyrouter = express.Router();
Dummyrouter.post(
"/ProductUpsertdummy",
tokenValidator,
AddProductControllerdumy
);
export default Dummyrouter;

View File

@@ -4,15 +4,11 @@ import {
recentDataController,
searchProjectController,
searchTrashProjectController,
} from "../../V1/v1Controllers/homeController/v1homeController.ts";
} from "../v1Controllers/homeController/v1homeController.ts";
const V1homeRoutes = express.Router();
V1homeRoutes.get(
"/RecentlyViewed",
tokenValidator,
recentDataController
);
V1homeRoutes.get("/RecentlyViewed", tokenValidator, recentDataController);
V1homeRoutes.get(
"/search/searchProjects",
tokenValidator,

View File

@@ -6,7 +6,7 @@ import {
RemoveProject,
updateProjectController,
ViewData,
} from "../../V1/v1Controllers/projectController/v1projectController.ts";
} from "../v1Controllers/projectController/v1projectController.ts";
import { tokenValidator } from "../../../shared/utils/token.ts";
const V1projectRouter = express.Router();
@@ -17,11 +17,7 @@ V1projectRouter.post(
tokenValidator,
ProjectDuplicateController
);
V1projectRouter.get(
"/Projects",
tokenValidator,
GetProjects
);
V1projectRouter.get("/Projects", tokenValidator, GetProjects);
V1projectRouter.patch(
"/Projects/Archive/:projectId",
tokenValidator,
@@ -33,10 +29,6 @@ V1projectRouter.patch(
tokenValidator,
updateProjectController
);
V1projectRouter.get(
"/Project/:projectId",
tokenValidator,
ViewData
);
V1projectRouter.get("/Project/:projectId", tokenValidator, ViewData);
export default V1projectRouter;

View File

@@ -0,0 +1,35 @@
import express from "express";
import { tokenValidator } from "../../../shared/utils/token.ts";
import { getALLthreads, threadComment, threadCommentDelete, threadCreate, threaddelete, threadUpdateTitle } from "../v1Controllers/threadController/threadController.ts";
const V1ThreadRoutes = express.Router();
V1ThreadRoutes.post(
"/upsetThread/",
tokenValidator,
threadCreate
);
V1ThreadRoutes.patch(
"/Thread/delete",
tokenValidator,
threaddelete
);
V1ThreadRoutes.patch(
"/Thread/updateTitle",
tokenValidator,
threadUpdateTitle
);
V1ThreadRoutes.post(
"/Thread/addComment",
tokenValidator,
threadComment
);
V1ThreadRoutes.patch(
"/Thread/deleteComment",
tokenValidator,
threadCommentDelete
);
V1ThreadRoutes.get(
"/Threads/:projectId",
tokenValidator,
getALLthreads
);
export default V1ThreadRoutes

View File

@@ -4,23 +4,11 @@ import {
DeleteTrashData,
GetTrashList,
RestoreTrash,
} from "../../V1/v1Controllers/trashController/v1trashController.ts";
} from "../v1Controllers/trashController/v1trashController.ts";
const V1TrashRoutes = express.Router();
V1TrashRoutes.get(
"/TrashItems",
tokenValidator,
GetTrashList
);
V1TrashRoutes.get("/TrashItems", tokenValidator, GetTrashList);
V1TrashRoutes.patch(
"/Trash/restore",
tokenValidator,
RestoreTrash
);
V1TrashRoutes.patch(
"/Trash/Delete",
tokenValidator,
DeleteTrashData
);
V1TrashRoutes.patch("/Trash/restore", tokenValidator, RestoreTrash);
V1TrashRoutes.patch("/Trash/Delete", tokenValidator, DeleteTrashData);
export default V1TrashRoutes;

View File

@@ -0,0 +1,21 @@
import express from "express";
import { tokenValidator } from "../../../shared/utils/token.ts";
import {
GetversionHistory,
GetversionList,
rollbackcontroller,
versionAddcontroller,
} from "../v1Controllers/versionController/versioncontroller.ts";
const V1versionRoutes = express.Router();
V1versionRoutes.post("/generateVersion", tokenValidator, versionAddcontroller);
V1versionRoutes.get(
"/version/:versionId/:projectId",
tokenValidator,
GetversionList
);
V1versionRoutes.get("/:projectId/versions", tokenValidator, GetversionHistory);
V1versionRoutes.post("/version/rollback", tokenValidator, rollbackcontroller);
export default V1versionRoutes;

View File

@@ -21,7 +21,7 @@ V1FloatWidget.patch(
DeleteFloatController
);
V1FloatWidget.get(
"/floatWidgets/:zoneUuid/:projectId",
"/floatWidgets/:zoneUuid/:projectId/:versionId",
tokenValidator,
GetFloatController
);

View File

@@ -20,7 +20,7 @@ V1Template.post(
AddTemToZoneController
);
V1Template.get(
"/template/data/:projectId",
"/template/data/:projectId/:versionId",
tokenValidator,
GetTemplateController
);

View File

@@ -23,7 +23,7 @@ V1Widget3d.patch(
Update3DwidgetController
);
V1Widget3d.get(
"/widget3d/data/:zoneUuid/:projectId",
"/widget3d/data/:zoneUuid/:projectId/:versionId",
tokenValidator,
Get3DWidgetController
);

View File

@@ -0,0 +1,17 @@
import express from "express";
import { tokenValidator } from "../../../../shared/utils/token.ts";
import { autoSaveRestore, clearAutoSaveRestore } from "../../v1Controllers/yjsController/auto-saveControlle.ts";
const V1AutoSaveRoutes = express.Router();
V1AutoSaveRoutes.get(
"/restoreAutoSave/",
// tokenValidator,
autoSaveRestore
);
V1AutoSaveRoutes.post(
"/clearSnapAutoSave/",
// tokenValidator,
clearAutoSaveRestore
);
export default V1AutoSaveRoutes

View File

@@ -0,0 +1,16 @@
import express from "express";
import { SnapshotList, SnapshotRestore } from "../../v1Controllers/yjsController/yjsSnapController.ts";
import { tokenValidator } from "../../../../shared/utils/token.ts";
const V1SnapshotRoutes = express.Router();
V1SnapshotRoutes.get(
"/restoreSnap/",
// tokenValidator,
SnapshotRestore
);
V1SnapshotRoutes.get(
"/listSnap/",
// tokenValidator,
SnapshotList
);
export default V1SnapshotRoutes

View File

@@ -38,6 +38,11 @@ import V1Widget from "./V1/v1Routes/vizRoutes.ts/v1-widgetRoutes.ts";
import V1Widget3d from "./V1/v1Routes/vizRoutes.ts/v1-widget3dRoutes.ts";
import V1Product from "./V1/v1Routes/SimulationRoutes/v1-ProductRoutes.ts";
import V1Aisle from "./V1/v1Routes/BuilderRoutes/V1-AisleRoutes.ts";
import V1ThreadRoutes from "./V1/v1Routes/v1-threadRoutes.ts";
import V1versionRoutes from "./V1/v1Routes/v1-versionRoutes.ts";
import Dummyrouter from "./V1/v1Routes/dummyroutes.ts";
import V1SnapshotRoutes from "./V1/v1Routes/yjsRoutes.ts/snapshotRoutes.ts";
import V1AutoSaveRoutes from "./V1/v1Routes/yjsRoutes.ts/autosaveRoutes.ts";
redis;
const app = express();
app.use(cors());
@@ -90,5 +95,10 @@ app.use("/api/V1", V1Widget);
app.use("/api/V1", V1Widget3d);
app.use("/api/V1", V1Product);
app.use("/api/V1", V1Aisle);
app.use("/api/V1", V1ThreadRoutes);
app.use("/api/V1", V1versionRoutes);
app.use("/api/V1", Dummyrouter);
app.use("/api/V1", V1SnapshotRoutes);
app.use("/api/V1", V1AutoSaveRoutes);
export default app;

View File

@@ -5,13 +5,29 @@ import fs from "fs";
const server = http.createServer(app);
let swaggerDocument = {};
let swaggerNewVersionDocument = {};
try {
swaggerDocument = JSON.parse(fs.readFileSync("swagger-output.json", "utf-8"));
} catch (error) {
console.error("Error loading Swagger JSON:", error);
}
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
// app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
app.use(
"/api-docs",
swaggerUi.serveFiles(swaggerDocument),
swaggerUi.setup(swaggerDocument)
);
// app.use(
// "/NewVersion/api-docs",
// swaggerUi.serve,
// swaggerUi.setup(swaggerNewVersionDocument)
// );
app.use(
"/NewVersion/api-docs",
swaggerUi.serveFiles(swaggerNewVersionDocument),
swaggerUi.setup(swaggerNewVersionDocument)
);
const organization = process.env.ORGANIZATION_NAME || "defaultOrganization";
if (!organization) {
@@ -22,4 +38,7 @@ const PORT = process.env.API_PORT;
server.listen(PORT, () => {
console.log(`API-Server running on http://localhost:${PORT}`);
console.log(`Swagger UI available at http://localhost:${PORT}/api-docs`);
console.log(
`Swagger UI available at http://localhost:${PORT}/NewVersion/api-docs`
);
});