Skip to content

SDK Quick Start

1. Create a client

import { SimpleFeatureRequestsClient } from '@mindsize/simple-feature-requests-sdk';

const client = new SimpleFeatureRequestsClient({
  baseUrl: 'https://api.example.com',
  getAccessToken: async () => {
    // Return your Clerk session token, or null for unauthenticated requests.
    return await clerkSession.getToken(); // example
  },
});

For public-only or script usage, omit getAccessToken:

const client = new SimpleFeatureRequestsClient({
  baseUrl: 'https://api.example.com',
});

Use the API base URL your deployment provides (no trailing slash). The SDK sends GraphQL requests with POST to that origin ({baseUrl}/, i.e. the API root).

2. Call the API

// Public: no auth required
const message = await client.general.hello();
console.log(message);

// Authenticated: list teams for the current user
const teams = await client.teams.listForCurrentUser();

// Get a single team
const team = await client.teams.get('team-uuid');
if (team) console.log(team.name);

// Create a request on a board (auth rules depend on project/board visibility)
const request = await client.requests.create({
  boardId: 'board-uuid',
  title: 'New feature idea',
  description: 'Optional description',
  // statusId and tagIds optional; server may apply default status
});

3. Handle errors

The SDK throws SdkError on API or network failures. Use code to branch:

import { SimpleFeatureRequestsClient, SdkError, isSdkError } from '@mindsize/simple-feature-requests-sdk';

try {
  await client.teams.get('team-id');
} catch (err) {
  if (isSdkError(err)) {
    switch (err.code) {
      case 'UNAUTHORIZED':
        // Redirect to sign-in
        break;
      case 'FORBIDDEN':
        // No permission
        break;
      case 'NOT_FOUND':
        // Resource missing
        break;
      default:
        console.error(err.message);
    }
  } else {
    throw err;
  }
}

See Errors for all error codes and API Reference for available methods.