mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 07:16:17 +08:00
fix: remove tailing slashes from new endpoint urls (@fehmer) (#5745)
!nuf
This commit is contained in:
parent
c33a087161
commit
2d24fc323e
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue