Skip to content

Commit 7cab731

Browse files
authored
Merge pull request #168 from csfloat/feature/csfloat-endpoints
Updates Various Endpoints to `csfloat.com`
2 parents e432e43 + 48924de commit 7cab731

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/lib/bridge/handlers/fetch_inspect_info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface FetchInspectInfoResponse {
5252
export const FetchInspectInfo = new SimpleHandler<FetchInspectInfoRequest, FetchInspectInfoResponse>(
5353
RequestType.FETCH_INSPECT_INFO,
5454
(req) => {
55-
const apiUrl = `https://api.csgofloat.com/?url=${req.link}&minimal=true${
55+
const apiUrl = `https://api.csfloat.com/?url=${req.link}&minimal=true${
5656
req.listPrice ? '&listPrice=' + req.listPrice : ''
5757
}`;
5858
return fetch(apiUrl).then((resp) => {

src/lib/bridge/handlers/fetch_pending_trades.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,28 @@ export interface FetchPendingTradesResponse {
1212
export const FetchPendingTrades = new SimpleHandler<FetchPendingTradesRequest, FetchPendingTradesResponse>(
1313
RequestType.FETCH_PENDING_TRADES,
1414
async (req) => {
15-
return fetch(`https://csgofloat.com/api/v1/me/pending-trades`, {
16-
credentials: 'include',
17-
}).then((resp) => {
15+
try {
16+
const resp = await fetch(`https://csfloat.com/api/v1/me/pending-trades`, {
17+
credentials: 'include',
18+
});
19+
20+
if (resp.status !== 200) {
21+
throw new Error('invalid status');
22+
}
23+
1824
return resp.json() as Promise<FetchPendingTradesResponse>;
19-
});
25+
} catch (e) {
26+
// Try the old CSGOFloat URL (in case they have an old session from there)
27+
// Of note, this can be removed ~1 week after the migration.
28+
const resp = await fetch(`https://csgofloat.com/api/v1/me/pending-trades`, {
29+
credentials: 'include',
30+
});
31+
32+
if (resp.status !== 200) {
33+
throw new Error('invalid status');
34+
}
35+
36+
return resp.json();
37+
}
2038
}
2139
);

src/lib/bridge/handlers/fetch_stall.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface FetchStallResponseError {
1919
export const FetchStall = new SimpleHandler<FetchStallRequest, FetchStallResponse>(
2020
RequestType.FETCH_STALL,
2121
async (req) => {
22-
return fetch(`https://csgofloat.com/api/v1/users/${req.steam_id64}/stall`).then((resp) => {
22+
return fetch(`https://csfloat.com/api/v1/users/${req.steam_id64}/stall`).then((resp) => {
2323
return resp.json().then((json: FetchStallResponse | FetchStallResponseError) => {
2424
if (resp.ok) {
2525
return json;

0 commit comments

Comments
 (0)