Skip to content
Open
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
3 changes: 2 additions & 1 deletion core/src/exchanges/limitless/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class LimitlessFetcher implements IExchangeFetcher<LimitlessRawMarket, Li
const httpClient = new HttpClient({
baseURL: this.apiUrl,
apiKey: this.apiKey,
timeout: 30000,
});
const marketFetcher = new MarketFetcher(httpClient);

Expand Down Expand Up @@ -259,7 +260,7 @@ export class LimitlessFetcher implements IExchangeFetcher<LimitlessRawMarket, Li

private async fetchRawEventBySlug(slug: string): Promise<LimitlessRawEvent[]> {
const { HttpClient, MarketFetcher } = await import('@limitless-exchange/sdk');
const httpClient = new HttpClient({ baseURL: this.apiUrl });
const httpClient = new HttpClient({ baseURL: this.apiUrl, timeout: 30000 });
const marketFetcher = new MarketFetcher(httpClient);

const market = await marketFetcher.getMarket(slug);
Expand Down
22 changes: 15 additions & 7 deletions core/src/server/test-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,32 @@
*/

const BASE_URL = 'http://localhost:3847';
const REQUEST_TIMEOUT_MS = 30_000;

async function fetchWithTimeout(url, options = {}) {
return fetch(url, {
...options,
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
});
}

async function testHealthCheck() {
console.log('\nTesting health check...');
const response = await fetch(`${BASE_URL}/health`);
const response = await fetchWithTimeout(`${BASE_URL}/health`);
const data = await response.json();
console.log('Health check:', data);
}

async function testVersion() {
console.log('\nTesting version endpoint...');
const response = await fetch(`${BASE_URL}/version`);
const response = await fetchWithTimeout(`${BASE_URL}/version`);
const data = await response.json();
console.log('Version:', data);
}

async function testFetchMarkets() {
console.log('\nTesting fetchMarkets (Polymarket)...');
const response = await fetch(`${BASE_URL}/api/polymarket/fetchMarkets`, {
const response = await fetchWithTimeout(`${BASE_URL}/api/polymarket/fetchMarkets`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand All @@ -42,7 +50,7 @@ async function testFetchMarkets() {

async function testSearchMarkets() {
console.log('\nTesting searchMarkets (Kalshi)...');
const response = await fetch(`${BASE_URL}/api/kalshi/searchMarkets`, {
const response = await fetchWithTimeout(`${BASE_URL}/api/kalshi/searchMarkets`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand All @@ -63,7 +71,7 @@ async function testSearchMarkets() {

async function testGetMarketsBySlug() {
console.log('\nTesting getMarketsBySlug (Polymarket)...');
const response = await fetch(`${BASE_URL}/api/polymarket/getMarketsBySlug`, {
const response = await fetchWithTimeout(`${BASE_URL}/api/polymarket/getMarketsBySlug`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand All @@ -84,7 +92,7 @@ async function testFetchOHLCV() {
console.log('\nTesting fetchOHLCV (Polymarket)...');

// First, get a market to extract an outcome ID
const marketsResponse = await fetch(`${BASE_URL}/api/polymarket/searchMarkets`, {
const marketsResponse = await fetchWithTimeout(`${BASE_URL}/api/polymarket/searchMarkets`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand All @@ -101,7 +109,7 @@ async function testFetchOHLCV() {
const outcomeId = marketsData.data[0].outcomes[0].id;
console.log(` Using outcome ID: ${outcomeId.substring(0, 20)}...`);

const response = await fetch(`${BASE_URL}/api/polymarket/fetchOHLCV`, {
const response = await fetchWithTimeout(`${BASE_URL}/api/polymarket/fetchOHLCV`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand Down
Loading