api/v2 routing added for the userDatas
This commit is contained in:
@@ -52,6 +52,7 @@ export const SignInController = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { Email, Password, fingerprint } = req.body;
|
||||
console.log("req.body: ", req.body);
|
||||
if (!fingerprint || !Email || !Password) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
@@ -74,6 +75,7 @@ export const SignInController = async (
|
||||
case "Already LoggedIn on another browser....Please logout!!!":
|
||||
res.status(403).json({
|
||||
message: "Already LoggedIn on another browser....Please logout!!!",
|
||||
ForceLogoutData: result.data,
|
||||
});
|
||||
break;
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
import { Request, Response } from "express";
|
||||
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
import {
|
||||
GetCamers,
|
||||
SetCamera,
|
||||
} from "../../../../shared/services/builder/cameraService.ts";
|
||||
|
||||
export const SetNewCamera = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
const { position, target, rotation, projectId, versionId } = req.body;
|
||||
if (
|
||||
!organization ||
|
||||
!role ||
|
||||
!userId ||
|
||||
!position ||
|
||||
!target ||
|
||||
!rotation ||
|
||||
!projectId ||
|
||||
!versionId
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
position,
|
||||
target,
|
||||
rotation,
|
||||
projectId,
|
||||
versionId,
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
};
|
||||
const result = await SetCamera(data);
|
||||
|
||||
switch (result.status) {
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
TrashDatas: [],
|
||||
});
|
||||
break;
|
||||
|
||||
case "Update Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const CameraList = 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 result = await GetCamers({
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
TrashDatas: [],
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -94,7 +94,7 @@ app.use("/api/v1", trashRouter);
|
||||
app.use("/api/v1", homePageRouter);
|
||||
|
||||
//New versions--based on the token and role based
|
||||
app.use("/api", Authrouter);
|
||||
app.use("/api/v2", Authrouter);
|
||||
app.use("/api/v2", v1projectRouter);
|
||||
app.use("/api/v2", v1TrashRoutes);
|
||||
app.use("/api/v2", v1homeRoutes);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import projectModel from "../../model/project/project-model.ts";
|
||||
import userModel from "../../model/user-Model.ts";
|
||||
import versionModel from "../../model/version/versionModel.ts";
|
||||
import UsersDataModel from "../../V1Models/Auth/user.ts";
|
||||
import cameraModel from "../../V1Models/Builder/cameraModel.ts";
|
||||
import { existingProjectById } from "../helpers/ProjecthelperFn.ts";
|
||||
import { existingProjectById } from "../helpers/v1projecthelperFns.ts";
|
||||
interface IcameraData {
|
||||
userId: string;
|
||||
role: string;
|
||||
position: Object;
|
||||
target: Object;
|
||||
rotation: Object;
|
||||
@@ -16,6 +14,7 @@ interface IcameraData {
|
||||
interface IgetCameras {
|
||||
organization: string;
|
||||
userId?: string;
|
||||
role: string;
|
||||
}
|
||||
export const SetCamera = async (
|
||||
data: IcameraData
|
||||
@@ -23,6 +22,7 @@ export const SetCamera = async (
|
||||
try {
|
||||
const {
|
||||
userId,
|
||||
role,
|
||||
position,
|
||||
target,
|
||||
rotation,
|
||||
@@ -65,7 +65,7 @@ export const SetCamera = async (
|
||||
});
|
||||
|
||||
return {
|
||||
status: "Creation Success",
|
||||
status: "Success",
|
||||
data: newCamera,
|
||||
};
|
||||
}
|
||||
@@ -84,13 +84,13 @@ export const SetCamera = async (
|
||||
export const GetCamers = async (
|
||||
data: IgetCameras
|
||||
): Promise<{ status: string; data?: Object }> => {
|
||||
const { userId, organization } = data;
|
||||
const { userId, organization, role } = data;
|
||||
try {
|
||||
const findCamera = await cameraModel(organization).findOne({
|
||||
userId: userId,
|
||||
});
|
||||
if (!findCamera) {
|
||||
return { status: "user not found" };
|
||||
return { status: "Camera not found" };
|
||||
} else {
|
||||
return { status: "Success", data: findCamera };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user