diff options
author | Christian Fehmer <[email protected]> | 2024-08-08 18:12:50 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-08-08 18:12:50 +0200 |
commit | 2d24fc323e94aae83ae4897938f9d8c0f8b8542b (patch) | |
tree | 885c1e966ccde1d5fd42d3656ca09e0661a6003d | |
parent | c33a087161203162af615fd9dba00a71da2a0b71 (diff) | |
download | monkeytype-2d24fc323e94aae83ae4897938f9d8c0f8b8542b.tar.gz monkeytype-2d24fc323e94aae83ae4897938f9d8c0f8b8542b.zip |
fix: remove tailing slashes from new endpoint urls (@fehmer) (#5745)
!nuf
-rw-r--r-- | frontend/src/ts/ape/adapters/ts-rest-adapter.ts | 16 | ||||
-rw-r--r-- | packages/contracts/src/admin.ts | 2 | ||||
-rw-r--r-- | packages/contracts/src/ape-keys.ts | 4 | ||||
-rw-r--r-- | packages/contracts/src/configs.ts | 6 | ||||
-rw-r--r-- | packages/contracts/src/psas.ts | 2 |
5 files changed, 12 insertions, 18 deletions
diff --git a/frontend/src/ts/ape/adapters/ts-rest-adapter.ts b/frontend/src/ts/ape/adapters/ts-rest-adapter.ts index ded38548e..835f812ae 100644 --- a/frontend/src/ts/ape/adapters/ts-rest-adapter.ts +++ b/frontend/src/ts/ape/adapters/ts-rest-adapter.ts @@ -3,7 +3,6 @@ import { Method } from "axios"; import { getIdToken } from "firebase/auth"; import { envConfig } from "../../constants/env-config"; import { getAuthenticatedUser, isAuthenticated } from "../../firebase"; -import { EndpointMetadata } from "@monkeytype/contracts/schemas/api"; function timeoutSignal(ms: number): AbortSignal { const ctrl = new AbortController(); @@ -17,22 +16,17 @@ function buildApi(timeout: number): (args: ApiFetcherArgs) => Promise<{ headers: Headers; }> { return async (request: ApiFetcherArgs) => { - const isPublicEndpoint = - (request.route.metadata as EndpointMetadata | undefined) - ?.authenticationOptions?.isPublic ?? false; - try { const headers: HeadersInit = { ...request.headers, "X-Client-Version": envConfig.clientVersion, }; - if (!isPublicEndpoint) { - const token = isAuthenticated() - ? await getIdToken(getAuthenticatedUser()) - : ""; - headers["Authorization"] = `Bearer ${token}`; - } + const token = isAuthenticated() + ? await getIdToken(getAuthenticatedUser()) + : ""; + + headers["Authorization"] = `Bearer ${token}`; const fetchOptions: RequestInit = { method: request.method as Method, diff --git a/packages/contracts/src/admin.ts b/packages/contracts/src/admin.ts index 0d68e7e41..76595e930 100644 --- a/packages/contracts/src/admin.ts +++ b/packages/contracts/src/admin.ts @@ -58,7 +58,7 @@ export const adminContract = c.router( summary: "test permission", description: "Check for admin permission for the current user", method: "GET", - path: "/", + path: "", responses: { 200: MonkeyResponseSchema, }, diff --git a/packages/contracts/src/ape-keys.ts b/packages/contracts/src/ape-keys.ts index c5657d32c..4b6801646 100644 --- a/packages/contracts/src/ape-keys.ts +++ b/packages/contracts/src/ape-keys.ts @@ -46,7 +46,7 @@ export const apeKeysContract = c.router( summary: "get ape keys", description: "Get ape keys of the current user.", method: "GET", - path: "/", + path: "", responses: { 200: GetApeKeyResponseSchema, }, @@ -55,7 +55,7 @@ export const apeKeysContract = c.router( summary: "add ape key", description: "Add an ape key for the current user.", method: "POST", - path: "/", + path: "", body: AddApeKeyRequestSchema.strict(), responses: { 200: AddApeKeyResponseSchema, diff --git a/packages/contracts/src/configs.ts b/packages/contracts/src/configs.ts index 8790de4df..115a27d5d 100644 --- a/packages/contracts/src/configs.ts +++ b/packages/contracts/src/configs.ts @@ -22,14 +22,14 @@ export const configsContract = c.router( summary: "get config", description: "Get config of the current user.", method: "GET", - path: "/", + path: "", responses: { 200: GetConfigResponseSchema, }, }, save: { method: "PATCH", - path: "/", + path: "", body: PartialConfigSchema.strict(), responses: { 200: MonkeyResponseSchema, @@ -40,7 +40,7 @@ export const configsContract = c.router( }, delete: { method: "DELETE", - path: "/", + path: "", body: c.noBody(), responses: { 200: MonkeyResponseSchema, diff --git a/packages/contracts/src/psas.ts b/packages/contracts/src/psas.ts index 25e2f3226..a37835732 100644 --- a/packages/contracts/src/psas.ts +++ b/packages/contracts/src/psas.ts @@ -17,7 +17,7 @@ export const psasContract = c.router( summary: "get psas", description: "Get list of public service announcements", method: "GET", - path: "/", + path: "", responses: { 200: GetPsaResponseSchema, }, |