Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.local.sample
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_MAX_AGE=3600000
REDIS_PREFIX=scix_
REDIS_CACHE_TTL=300
REDIS_CACHE_MAX_SIZE=5242880

# SEARCH
NEXT_PUBLIC_SEARCH_API_TIMEOUT_MS=30000
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"iron-session": "^6.3.1",
"lint-staged": "^11.2.6",
"msw": "^1.2.3",
"node-mocks-http": "^1.17.2",
"prettier": "^2.3.0",
"react-dom": "^18.3.1",
"react-is": "^17.0.2",
Expand Down
99 changes: 99 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions src/api/resolver/resolver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import axios from 'axios';
import { isBrowser } from '@/utils/common/guards';
import api, { ApiRequestConfig } from '@/api/api';
import { ApiTargets } from '@/api/models';
import { ADSQuery } from '@/api/types';
Expand All @@ -21,16 +23,26 @@ export const useResolverQuery: ADSQuery<IADSApiResolverParams, IADSApiResolverRe
});
};

const acceptOkOrNotFound = (status: number): boolean => status === 200 || status === 404;

export const fetchLinks: QueryFunction<IADSApiResolverResponse> = async ({ meta }) => {
const { params } = meta as { params: IADSApiResolverParams };
const resolverPath = `${ApiTargets.RESOLVER}/${params.bibcode}/${params.link_type}`;

if (isBrowser()) {
const { data } = await axios.get<IADSApiResolverResponse>(`/api/proxy${resolverPath}`, {
withCredentials: true,
validateStatus: acceptOkOrNotFound,
});
return data;
}

const config: ApiRequestConfig = {
method: 'GET',
url: `${ApiTargets.RESOLVER}/${params.bibcode}/${params.link_type}`,
validateStatus: (status) => status === 200 || status === 404,
url: resolverPath,
validateStatus: acceptOkOrNotFound,
};

const { data } = await api.request<IADSApiResolverResponse>(config);

return data;
};
Loading
Loading