Skip to content

Commit 3aa5e0c

Browse files
committed
refactor: remove authentication routes and comment out domain, link, and notification handling logic
1 parent 32f31df commit 3aa5e0c

6 files changed

Lines changed: 222 additions & 232 deletions

File tree

apps/api/app/v1/[[...route]]/route.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { logger } from "hono/logger";
44
import { handle } from "hono/vercel";
55
import health from "../routes/alive";
66
import ai from "../routes/ai";
7-
import auth from "../routes/auth";
87
import user from "../routes/user";
98
import project from "../routes/project";
109
import api from "../routes/api";
@@ -66,7 +65,6 @@ app.use(rateLimitHandler);
6665

6766
// Import routes
6867
app.route("/health", health);
69-
app.route("/auth", auth);
7068
app.route("/store", store);
7169
app.route("/ai", ai);
7270
app.route("/user", user);

apps/api/app/v1/routes/auth.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

apps/api/app/v1/routes/domain.ts

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -42,61 +42,61 @@ domain.post("/status", async (c) => {
4242
domain.use(checkUser);
4343
domain.use(auditLogs);
4444

45-
domain.post("/create", async (c) => {
46-
const { name, alias, status, projectId } = await c.req.json();
47-
if (!name || !projectId) {
48-
return c.json({ message: "Name and ProjectId are required" }, 400);
49-
}
50-
// Check if the domain already exists
51-
const existingDomain = await prisma.domain.findFirst({
52-
where: {
53-
name: name,
54-
},
55-
select: { id: true },
56-
});
57-
if (existingDomain) {
58-
return c.json({ message: "Domain already exists", existingDomain }, 409);
59-
}
60-
console.log("No existing domain found, proceeding to create a new one");
61-
// Create the new domain
62-
const session = await auth.api.getSession({ headers: c.req.raw.headers });
63-
if (!session?.user?.id) {
64-
return c.json({ message: "Unauthorized" }, 401);
65-
}
66-
const userId = session.user.id;
67-
const project = await prisma.project.findUnique({
68-
where: { id: projectId },
69-
select: { userId: true },
70-
});
71-
if (!project) {
72-
return c.json({ message: "Project not found" }, 404);
73-
}
74-
if (project.userId !== userId) {
75-
return c.json({ message: "Forbidden" }, 403);
76-
}
77-
console.log("User is authorized to create a domain for this project");
78-
// Create the domain
79-
const telementry_key = await generateTelemetryKey(name);
80-
if (!telementry_key) {
81-
return c.json({ message: "Failed to generate telemetry key" }, 500);
82-
}
83-
console.log("Generated telemetry key:", telementry_key);
45+
// domain.post("/create", async (c) => {
46+
// const { name, alias, status, projectId } = await c.req.json();
47+
// if (!name || !projectId) {
48+
// return c.json({ message: "Name and ProjectId are required" }, 400);
49+
// }
50+
// // Check if the domain already exists
51+
// const existingDomain = await prisma.domain.findFirst({
52+
// where: {
53+
// name: name,
54+
// },
55+
// select: { id: true },
56+
// });
57+
// if (existingDomain) {
58+
// return c.json({ message: "Domain already exists", existingDomain }, 409);
59+
// }
60+
// console.log("No existing domain found, proceeding to create a new one");
61+
// // Create the new domain
62+
// const session = await auth.api.getSession({ headers: c.req.raw.headers });
63+
// if (!session?.user?.id) {
64+
// return c.json({ message: "Unauthorized" }, 401);
65+
// }
66+
// const userId = session.user.id;
67+
// const project = await prisma.project.findUnique({
68+
// where: { id: projectId },
69+
// select: { userId: true },
70+
// });
71+
// if (!project) {
72+
// return c.json({ message: "Project not found" }, 404);
73+
// }
74+
// if (project.userId !== userId) {
75+
// return c.json({ message: "Forbidden" }, 403);
76+
// }
77+
// console.log("User is authorized to create a domain for this project");
78+
// // Create the domain
79+
// const telementry_key = await generateTelemetryKey(name);
80+
// if (!telementry_key) {
81+
// return c.json({ message: "Failed to generate telemetry key" }, 500);
82+
// }
83+
// console.log("Generated telemetry key:", telementry_key);
8484

85-
const newDomain = await prisma.domain.create({
86-
data: {
87-
name: name,
88-
alias: alias,
89-
status: status || "Pending",
90-
projectId,
91-
telementry_key,
92-
},
93-
});
94-
if (!newDomain) {
95-
return c.json({ message: "Failed to create domain" }, 500);
96-
}
97-
console.log("Created new domain:", newDomain);
98-
return c.json({ domain: newDomain }, 201);
99-
});
85+
// const newDomain = await prisma.domain.create({
86+
// data: {
87+
// name: name,
88+
// alias: alias,
89+
// status: status || "Pending",
90+
// projectId,
91+
// telementry_key,
92+
// },
93+
// });
94+
// if (!newDomain) {
95+
// return c.json({ message: "Failed to create domain" }, 500);
96+
// }
97+
// console.log("Created new domain:", newDomain);
98+
// return c.json({ domain: newDomain }, 201);
99+
// });
100100

101101
domain.post("/all", async (c) => {
102102
const { projectId } = await c.req.json();
@@ -118,36 +118,36 @@ domain.post("/all", async (c) => {
118118
});
119119

120120
// Delete route for domain
121-
domain.delete("/delete", async (c) => {
122-
const { id } = await c.req.json();
123-
if (!id) {
124-
return c.json({ message: "Domain id is required" }, 400);
125-
}
126-
try {
127-
const session = await auth.api.getSession({ headers: c.req.raw.headers });
128-
if (!session?.user?.id) {
129-
return c.json({ message: "Unauthorized" }, 401);
130-
}
121+
// domain.delete("/delete", async (c) => {
122+
// const { id } = await c.req.json();
123+
// if (!id) {
124+
// return c.json({ message: "Domain id is required" }, 400);
125+
// }
126+
// try {
127+
// const session = await auth.api.getSession({ headers: c.req.raw.headers });
128+
// if (!session?.user?.id) {
129+
// return c.json({ message: "Unauthorized" }, 401);
130+
// }
131131

132-
const dom = await prisma.domain.findUnique({
133-
where: { id },
134-
select: { id: true, project: { select: { userId: true } } },
135-
});
136-
if (!dom) {
137-
return c.json({ message: "Not found" }, 404);
138-
}
139-
if (dom.project.userId !== session.user.id) {
140-
return c.json({ message: "Forbidden" }, 403);
141-
}
132+
// const dom = await prisma.domain.findUnique({
133+
// where: { id },
134+
// select: { id: true, project: { select: { userId: true } } },
135+
// });
136+
// if (!dom) {
137+
// return c.json({ message: "Not found" }, 404);
138+
// }
139+
// if (dom.project.userId !== session.user.id) {
140+
// return c.json({ message: "Forbidden" }, 403);
141+
// }
142142

143-
const deletedDomain = await prisma.domain.delete({
144-
where: { id },
145-
});
146-
return c.json({ message: "Domain deleted", domain: deletedDomain }, 200);
147-
} catch (error) {
148-
console.error("Error deleting domain:", error);
149-
return c.json({ message: "Failed to delete domain" }, 500);
150-
}
151-
});
143+
// const deletedDomain = await prisma.domain.delete({
144+
// where: { id },
145+
// });
146+
// return c.json({ message: "Domain deleted", domain: deletedDomain }, 200);
147+
// } catch (error) {
148+
// console.error("Error deleting domain:", error);
149+
// return c.json({ message: "Failed to delete domain" }, 500);
150+
// }
151+
// });
152152

153153
export default domain;

apps/api/app/v1/routes/link.ts

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -51,76 +51,76 @@ link.get("/:containerId/all", async (c) => {
5151
}
5252
});
5353

54-
link.delete("/delete", async (c) => {
55-
const { id } = await c.req.json();
56-
if (!id) {
57-
return c.json({ message: "Link id is required" }, 400);
58-
}
54+
// link.delete("/delete", async (c) => {
55+
// const { id } = await c.req.json();
56+
// if (!id) {
57+
// return c.json({ message: "Link id is required" }, 400);
58+
// }
5959

60-
try {
61-
const user = c.get("user");
62-
if (!user.id) {
63-
return c.json({ message: "Unauthorized" }, 401);
64-
}
60+
// try {
61+
// const user = c.get("user");
62+
// if (!user.id) {
63+
// return c.json({ message: "Unauthorized" }, 401);
64+
// }
6565

66-
const link = await prisma.links.findUnique({
67-
where: { id },
68-
select: {
69-
id: true,
70-
container: { select: { project: { select: { userId: true } } } },
71-
},
72-
});
73-
if (!link) {
74-
return c.json({ message: "Not found" }, 404);
75-
}
76-
if (link.container.project.userId !== user.id) {
77-
return c.json({ message: "Forbidden" }, 403);
78-
}
66+
// const link = await prisma.links.findUnique({
67+
// where: { id },
68+
// select: {
69+
// id: true,
70+
// container: { select: { project: { select: { userId: true } } } },
71+
// },
72+
// });
73+
// if (!link) {
74+
// return c.json({ message: "Not found" }, 404);
75+
// }
76+
// if (link.container.project.userId !== user.id) {
77+
// return c.json({ message: "Forbidden" }, 403);
78+
// }
7979

80-
const deletedLink = await prisma.links.delete({
81-
where: { id },
82-
});
83-
return c.json({ link: deletedLink }, 200);
84-
} catch (error) {
85-
console.error("Error deleting link:", error);
86-
return c.json({ message: "Error deleting link" }, 500);
87-
}
88-
});
80+
// const deletedLink = await prisma.links.delete({
81+
// where: { id },
82+
// });
83+
// return c.json({ link: deletedLink }, 200);
84+
// } catch (error) {
85+
// console.error("Error deleting link:", error);
86+
// return c.json({ message: "Error deleting link" }, 500);
87+
// }
88+
// });
8989

90-
link.post("/update", async (c) => {
91-
const { id, ...fields } = await c.req.json();
92-
if (!id) {
93-
return c.json({ message: "Link id is required" }, 400);
94-
}
95-
try {
96-
const user = c.get("user");
97-
if (!user.id) {
98-
return c.json({ message: "Unauthorized" }, 401);
99-
}
90+
// link.post("/update", async (c) => {
91+
// const { id, ...fields } = await c.req.json();
92+
// if (!id) {
93+
// return c.json({ message: "Link id is required" }, 400);
94+
// }
95+
// try {
96+
// const user = c.get("user");
97+
// if (!user.id) {
98+
// return c.json({ message: "Unauthorized" }, 401);
99+
// }
100100

101-
const link = await prisma.links.findUnique({
102-
where: { id },
103-
select: {
104-
id: true,
105-
container: { select: { project: { select: { userId: true } } } },
106-
},
107-
});
108-
if (!link) {
109-
return c.json({ message: "Not found" }, 404);
110-
}
111-
if (link.container.project.userId !== user.id) {
112-
return c.json({ message: "Forbidden" }, 403);
113-
}
101+
// const link = await prisma.links.findUnique({
102+
// where: { id },
103+
// select: {
104+
// id: true,
105+
// container: { select: { project: { select: { userId: true } } } },
106+
// },
107+
// });
108+
// if (!link) {
109+
// return c.json({ message: "Not found" }, 404);
110+
// }
111+
// if (link.container.project.userId !== user.id) {
112+
// return c.json({ message: "Forbidden" }, 403);
113+
// }
114114

115-
const updatedLink = await prisma.links.update({
116-
where: { id },
117-
data: { ...fields, updatedAt: new Date() },
118-
});
119-
return c.json({ link: updatedLink }, 200);
120-
} catch (error) {
121-
console.error("Failed to update link:", error);
122-
return c.json({ message: "Failed to update link" }, 500);
123-
}
124-
});
115+
// const updatedLink = await prisma.links.update({
116+
// where: { id },
117+
// data: { ...fields, updatedAt: new Date() },
118+
// });
119+
// return c.json({ link: updatedLink }, 200);
120+
// } catch (error) {
121+
// console.error("Failed to update link:", error);
122+
// return c.json({ message: "Failed to update link" }, 500);
123+
// }
124+
// });
125125

126126
export default link;

0 commit comments

Comments
 (0)