Skip to content

Commit 4f11124

Browse files
committed
fix: set default baseUrl to https://api.stackone.com
Create a central consts.ts file with DEFAULT_BASE_URL constant and use it as the default value in StackOneToolSet constructor. This allows users to use the SDK without explicitly providing a baseUrl. Closes #149
1 parent fb77062 commit 4f11124

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/consts.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Default base URL for StackOne API
3+
*/
4+
export const DEFAULT_BASE_URL = 'https://api.stackone.com';

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* StackOne AI Node.js SDK
33
*/
44

5+
export { DEFAULT_BASE_URL } from './consts';
56
export { BaseTool, StackOneTool, Tools } from './tool';
67
export { createFeedbackTool } from './tools/feedback';
78
export { StackOneAPIError, StackOneError } from './utils/errors';

src/tools/feedback.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { z } from 'zod';
2+
import { DEFAULT_BASE_URL } from '../consts';
23
import { BaseTool } from '../tool';
34
import type { ExecuteConfig, ExecuteOptions, JsonDict, ToolParameters } from '../types';
45
import { StackOneError } from '../utils/errors';
@@ -39,7 +40,7 @@ const feedbackInputSchema = z.object({
3940
export function createFeedbackTool(
4041
apiKey?: string,
4142
accountId?: string,
42-
baseUrl = 'https://api.stackone.com'
43+
baseUrl = DEFAULT_BASE_URL
4344
): BaseTool {
4445
const options: FeedbackToolOptions = {
4546
apiKey,
@@ -102,7 +103,7 @@ export function createFeedbackTool(
102103
}
103104

104105
const tool = new BaseTool(name, description, parameters, executeConfig, authHeaders);
105-
const resolvedBaseUrl = options.baseUrl || 'https://api.stackone.com';
106+
const resolvedBaseUrl = options.baseUrl || DEFAULT_BASE_URL;
106107

107108
tool.execute = async function (
108109
this: BaseTool,

src/toolsets/stackone.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DEFAULT_BASE_URL } from '../consts';
12
import { type StackOneTool, Tools } from '../tool';
23
import { createFeedbackTool } from '../tools/feedback';
34
import { type BaseToolSetConfig, ToolSet, ToolSetConfigError } from './base';
@@ -94,7 +95,7 @@ export class StackOneToolSet extends ToolSet {
9495

9596
// Initialise base class
9697
super({
97-
baseUrl: config?.baseUrl,
98+
baseUrl: config?.baseUrl || process.env.STACKONE_BASE_URL || DEFAULT_BASE_URL,
9899
authentication,
99100
headers,
100101
});

0 commit comments

Comments
 (0)