Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

refactor: utility handlers (#5510)

Aaryan Khandelwal747905a96d64
diff --git a/live/src/ce/lib/authentication.ts b/live/src/ce/lib/authentication.ts
index 291085e94d..3d5a1ea48e 100644
--- a/live/src/ce/lib/authentication.ts
+++ b/live/src/ce/lib/authentication.ts
@@ -4,14 +4,12 @@ import { TDocumentTypes } from "@/core/types/common.js";
type TArgs = {
connection: ConnectionConfiguration
- cookie: string | undefined;
+ cookie: string;
+ documentType: TDocumentTypes | undefined;
params: URLSearchParams;
}
-export const authenticateUser = (args: TArgs): Promise<void> => {
- const { params } = args;
- const documentType = params.get("documentType")?.toString() as
- | TDocumentTypes
- | undefined;
+export const authenticateUser = async (args: TArgs): Promise<void> => {
+ const { documentType } = args;
throw Error(`Authentication failed: Invalid document type ${documentType} provided.`);
}
\ No newline at end of file
diff --git a/live/src/ce/lib/update-document.ts b/live/src/ce/lib/update-document.ts
index f784785ddb..b998e154f5 100644
--- a/live/src/ce/lib/update-document.ts
+++ b/live/src/ce/lib/update-document.ts
@@ -2,16 +2,14 @@
import { TDocumentTypes } from "@/core/types/common.js";
type TArgs = {
- params: URLSearchParams;
+ cookie: string | undefined;
+ documentType: TDocumentTypes | undefined;
pageId: string;
+ params: URLSearchParams;
updatedDescription: Uint8Array;
- cookie: string | undefined;
}
-export const updateDocument = (args: TArgs): Promise<void> => {
- const { params } = args;
- const documentType = params.get("documentType")?.toString() as
- | TDocumentTypes
- | undefined;
+export const updateDocument = async (args: TArgs): Promise<void> => {
+ const { documentType } = args;
throw Error(`Update failed: Invalid document type ${documentType} provided.`);
}
\ No newline at end of file
diff --git a/live/src/core/lib/authentication.ts b/live/src/core/lib/authentication.ts
index 6403b065e3..581e5e8fa2 100644
--- a/live/src/core/lib/authentication.ts
+++ b/live/src/core/lib/authentication.ts
@@ -18,8 +18,6 @@ type Props = {
export const handleAuthentication = async (props: Props) => {
const { connection, cookie, params, token } = props;
// params
- const workspaceSlug = params.get("workspaceSlug")?.toString();
- const projectId = params.get("projectId")?.toString();
const documentType = params.get("documentType")?.toString() as
| TDocumentTypes
| undefined;
@@ -36,6 +34,9 @@ export const handleAuthentication = async (props: Props) => {
}
if (documentType === "project_page") {
+ // params
+ const workspaceSlug = params.get("workspaceSlug")?.toString();
+ const projectId = params.get("projectId")?.toString();
if (!workspaceSlug || !projectId) {
throw Error(
"Authentication failed: Incomplete query params. Either workspaceSlug or projectId is missing."
@@ -56,6 +57,7 @@ export const handleAuthentication = async (props: Props) => {
await authenticateUser({
connection,
cookie,
+ documentType,
params
});
}
diff --git a/live/src/server.ts b/live/src/server.ts
index 6610042362..a64a6878b2 100644
--- a/live/src/server.ts
+++ b/live/src/server.ts
@@ -108,10 +108,11 @@ const server = Server.configure({
await updatePageDescription(params, pageId, state, cookie);
} else {
await updateDocument({
- params,
+ cookie,
+ documentType,
pageId,
+ params,
updatedDescription: state,
- cookie,
})
}
} catch (error) {