api collaboration

This commit is contained in:
2025-10-22 10:28:18 +05:30
parent 2826199587
commit b58433d77f
33 changed files with 5391 additions and 526 deletions

View File

@@ -4,31 +4,31 @@ import {
GetNodesInProject,
projectCreationService,
projectDatas,
projectModification,
ViewProjectService,
} from "../../shared/services/projectService";
import { AuthenticatedRequest } from "../../shared/utils/token";
export const projectCreationController = async (
req: Request,
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const {
organization,
useableLanguage,
language,
projectName,
userId,
apiType,
apiProtocol,
application,
architecture,
description,
} = req.body;
if (
!organization ||
!useableLanguage ||
!language ||
!projectName ||
!userId ||
!apiType ||
!apiProtocol ||
!architecture ||
!application
) {
@@ -40,14 +40,15 @@ export const projectCreationController = async (
const data = {
organization,
projectName,
useableLanguage,
language,
description,
application,
userId,
apiType,
apiProtocol,
architecture,
};
const result = await projectCreationService(data);
console.log("result:projectcreate ", result);
switch (result.status) {
case "Project Already Exists":
@@ -95,24 +96,28 @@ export const getProjects = async (
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const { skip, limit } = req.params;
if (!organization || !userId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await projectDatas({ organization, userId });
console.log("result: ", result);
const skipdata = parseInt(skip);
const limitdata = parseInt(limit);
const result = await projectDatas({
organization,
userId,
skipdata,
limitdata,
});
switch (result.status) {
case "No project found":
res.status(200).json({});
res.status(404).json({});
break;
case "Success":
res.status(200).json({
// message: "Projec",
projectDatas: result.data,
});
res.status(200).json({ data: result.data });
break;
default:
res.status(500).json({
@@ -128,12 +133,13 @@ export const getProjects = async (
};
export const NodesCollectionsBasedOnproject = async (
req: Request,
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { projectId, organization } = req.params;
if (!organization || !projectId) {
const { organization, userId } = req.user || {};
const { projectId } = req.params;
if (!organization || !projectId || !userId) {
res.status(400).json({
message: "All fields are required",
});
@@ -142,14 +148,20 @@ export const NodesCollectionsBasedOnproject = async (
const data = {
organization,
projectId,
userId,
};
const result = await GetNodesInProject(data);
switch (result.status) {
case "project not found":
res.status(200).json({
res.status(404).json({
message: "project not found",
});
break;
case "User not found":
res.status(404).json({
message: "User not found",
});
break;
case "No collection Nodes present":
res.status(200).json({
message: "No collection Nodes present",
@@ -237,10 +249,10 @@ export const deleteProjectController = async (
switch (result.status) {
case "User not found":
res.status(200).json({ message: "User not found" });
res.status(404).json({ message: "User not found" });
break;
case "Project not found":
res.status(200).json({ message: "Project not found" });
res.status(404).json({ message: "Project not found" });
break;
case "No access granted to delete this project":
res
@@ -267,3 +279,67 @@ export const deleteProjectController = async (
});
}
};
export const updateProjectController = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { organization, userId } = req.user || {};
const {
projectId,
projectName,
application,
description,
language,
architecture,
} = req.body;
if (!organization || !userId || !projectId) {
res.status(400).json({
message: "All fields are required",
});
return;
}
const result = await projectModification({
projectId,
organization,
userId,
projectName,
application,
description,
language,
architecture,
});
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 access granted to delete this project":
res
.status(200)
.json({ message: "No access granted to update this project" });
break;
case "Project update unsuccessfull":
res.status(200).json({ message: "Project update unsuccessfull" });
break;
case "Success":
res.status(200).json({
message: "Project updated successfully",
});
break;
default:
res.status(500).json({
message: "Internal server error",
});
break;
}
} catch (error) {
res.status(500).json({
message: "Unknown error",
});
}
};