fix: remove tailing slashes from new endpoint urls (@fehmer) (#5745)

!nuf
This commit is contained in:
Christian Fehmer 2024-08-08 18:12:50 +02:00 committed by GitHub
parent c33a087161
commit 2d24fc323e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 12 additions and 18 deletions

View file

@ -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,

View file

@ -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,
},

View file

@ -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,

View file

@ -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,

View file

@ -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,
},