Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 33x 33x 33x 3073x 3073x 3073x 3073x 3073x 2964x 2964x 2964x 2964x 2964x 2964x 3073x 33x 33x | // Template api used by the API generator to generate the actual api (apiStore.gen.ts)
// see also (openapi-config.json)
// and https://redux-toolkit.js.org/rtk-query/usage/code-generation#usage
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
// Use the environment variable with a fallback to localhost:8001
export const baseUrl = import.meta.env.VITE_API_BASE_URL;
const defaultBaseQuery = fetchBaseQuery({ baseUrl: baseUrl, credentials: "include" })
const customBaseQuery = async (args, api, extraOptions) => {
const url = document.URL;
const match = url.match(/\/project\/(\d+)/);
const flowsheetId = match ? Number(match[1]) : null;
const argsUrl = new URL(args.url, baseUrl);
if (flowsheetId) {
argsUrl.searchParams.set("flowsheet", flowsheetId.toString());
Iif (typeof args === "string") {
// Append query param to URL
args = argsUrl.toString();
} else if (typeof args === "object") {
// Inject flowsheet into body (for POST, PUT, etc.)
const isJson =
args.body &&
typeof args.body === "object" &&
!(args.body instanceof FormData);
const newBody = isJson
? { ...args.body, flowsheet: flowsheetId }
: args.body;
args = {
...args,
url: argsUrl.toString(),
body: newBody,
};
}
}
return defaultBaseQuery(args, api, extraOptions);
};
// initialize an empty api service that we'll inject endpoints into later as needed
export const emptySplitApi = createApi({
baseQuery: customBaseQuery,
endpoints: () => ({}),
}); |