chore(FEEDBACK-0001): linting
This commit is contained in:
@@ -32,33 +32,33 @@ Implement the public-facing REST API endpoints that replicate context7's `/api/v
|
||||
|
||||
### Query Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `libraryName` | string | Yes | Library name to search for |
|
||||
| `query` | string | No | User's question for relevance ranking |
|
||||
| `limit` | integer | No | Max results (default: 10, max: 50) |
|
||||
| Parameter | Type | Required | Description |
|
||||
| ------------- | ------- | -------- | ------------------------------------- |
|
||||
| `libraryName` | string | Yes | Library name to search for |
|
||||
| `query` | string | No | User's question for relevance ranking |
|
||||
| `limit` | integer | No | Max results (default: 10, max: 50) |
|
||||
|
||||
### Response `200` (`type=json`, default):
|
||||
|
||||
```json
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"id": "/facebook/react",
|
||||
"title": "React",
|
||||
"description": "A JavaScript library for building user interfaces",
|
||||
"branch": "main",
|
||||
"lastUpdateDate": "2026-03-22T10:00:00Z",
|
||||
"state": "finalized",
|
||||
"totalTokens": 142000,
|
||||
"totalSnippets": 1247,
|
||||
"stars": 228000,
|
||||
"trustScore": 9.2,
|
||||
"benchmarkScore": 87,
|
||||
"versions": ["v18.3.0", "v17.0.2"],
|
||||
"source": "https://github.com/facebook/react"
|
||||
}
|
||||
]
|
||||
"results": [
|
||||
{
|
||||
"id": "/facebook/react",
|
||||
"title": "React",
|
||||
"description": "A JavaScript library for building user interfaces",
|
||||
"branch": "main",
|
||||
"lastUpdateDate": "2026-03-22T10:00:00Z",
|
||||
"state": "finalized",
|
||||
"totalTokens": 142000,
|
||||
"totalSnippets": 1247,
|
||||
"stars": 228000,
|
||||
"trustScore": 9.2,
|
||||
"benchmarkScore": 87,
|
||||
"versions": ["v18.3.0", "v17.0.2"],
|
||||
"source": "https://github.com/facebook/react"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -67,11 +67,11 @@ Note: `state: "finalized"` maps from TrueRef's `state: "indexed"` for compatibil
|
||||
### State Mapping
|
||||
|
||||
| TrueRef state | context7 state |
|
||||
|---------------|---------------|
|
||||
| `pending` | `initial` |
|
||||
| `indexing` | `initial` |
|
||||
| `indexed` | `finalized` |
|
||||
| `error` | `error` |
|
||||
| ------------- | -------------- |
|
||||
| `pending` | `initial` |
|
||||
| `indexing` | `initial` |
|
||||
| `indexed` | `finalized` |
|
||||
| `error` | `error` |
|
||||
|
||||
---
|
||||
|
||||
@@ -81,43 +81,43 @@ Note: `state: "finalized"` maps from TrueRef's `state: "indexed"` for compatibil
|
||||
|
||||
### Query Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `libraryId` | string | Yes | Library ID, e.g. `/facebook/react` or `/facebook/react/v18.3.0` |
|
||||
| `query` | string | Yes | Specific question about the library |
|
||||
| `type` | string | No | `json` (default) or `txt` (plain text for LLM injection) |
|
||||
| `tokens` | integer | No | Approximate max token count for response (default: 10000) |
|
||||
| Parameter | Type | Required | Description |
|
||||
| ----------- | ------- | -------- | --------------------------------------------------------------- |
|
||||
| `libraryId` | string | Yes | Library ID, e.g. `/facebook/react` or `/facebook/react/v18.3.0` |
|
||||
| `query` | string | Yes | Specific question about the library |
|
||||
| `type` | string | No | `json` (default) or `txt` (plain text for LLM injection) |
|
||||
| `tokens` | integer | No | Approximate max token count for response (default: 10000) |
|
||||
|
||||
### Response `200` (`type=json`):
|
||||
|
||||
```json
|
||||
{
|
||||
"snippets": [
|
||||
{
|
||||
"type": "code",
|
||||
"title": "Basic Component",
|
||||
"description": "Getting Started > Components",
|
||||
"language": "tsx",
|
||||
"codeList": [
|
||||
{
|
||||
"language": "tsx",
|
||||
"code": "function MyComponent() {\n return <div>Hello</div>;\n}"
|
||||
}
|
||||
],
|
||||
"id": "uuid",
|
||||
"tokenCount": 45,
|
||||
"pageTitle": "Getting Started"
|
||||
},
|
||||
{
|
||||
"type": "info",
|
||||
"text": "React components let you split the UI into independent...",
|
||||
"breadcrumb": "Core Concepts > Components",
|
||||
"pageId": "uuid",
|
||||
"tokenCount": 120
|
||||
}
|
||||
],
|
||||
"rules": ["Always use functional components", "..."],
|
||||
"totalTokens": 2840
|
||||
"snippets": [
|
||||
{
|
||||
"type": "code",
|
||||
"title": "Basic Component",
|
||||
"description": "Getting Started > Components",
|
||||
"language": "tsx",
|
||||
"codeList": [
|
||||
{
|
||||
"language": "tsx",
|
||||
"code": "function MyComponent() {\n return <div>Hello</div>;\n}"
|
||||
}
|
||||
],
|
||||
"id": "uuid",
|
||||
"tokenCount": 45,
|
||||
"pageTitle": "Getting Started"
|
||||
},
|
||||
{
|
||||
"type": "info",
|
||||
"text": "React components let you split the UI into independent...",
|
||||
"breadcrumb": "Core Concepts > Components",
|
||||
"pageId": "uuid",
|
||||
"tokenCount": 120
|
||||
}
|
||||
],
|
||||
"rules": ["Always use functional components", "..."],
|
||||
"totalTokens": 2840
|
||||
}
|
||||
```
|
||||
|
||||
@@ -125,7 +125,7 @@ Note: `state: "finalized"` maps from TrueRef's `state: "indexed"` for compatibil
|
||||
|
||||
Plain text formatted for direct LLM context injection:
|
||||
|
||||
```
|
||||
````
|
||||
## Library Rules
|
||||
- Always use functional components
|
||||
- Use hooks for state management
|
||||
@@ -139,15 +139,17 @@ Plain text formatted for direct LLM context injection:
|
||||
function MyComponent() {
|
||||
return <div>Hello</div>;
|
||||
}
|
||||
```
|
||||
````
|
||||
|
||||
---
|
||||
|
||||
### React components let you split the UI...
|
||||
*Core Concepts > Components*
|
||||
|
||||
_Core Concepts > Components_
|
||||
|
||||
React components let you split the UI into independent, reusable pieces...
|
||||
```
|
||||
|
||||
````
|
||||
|
||||
---
|
||||
|
||||
@@ -167,7 +169,7 @@ function parseLibraryId(libraryId: string): {
|
||||
version: match[3],
|
||||
};
|
||||
}
|
||||
```
|
||||
````
|
||||
|
||||
---
|
||||
|
||||
@@ -176,20 +178,17 @@ function parseLibraryId(libraryId: string): {
|
||||
The `tokens` parameter limits the total response size. Snippets are added greedily until the budget is exhausted:
|
||||
|
||||
```typescript
|
||||
function selectSnippetsWithinBudget(
|
||||
snippets: Snippet[],
|
||||
maxTokens: number
|
||||
): Snippet[] {
|
||||
const selected: Snippet[] = [];
|
||||
let usedTokens = 0;
|
||||
function selectSnippetsWithinBudget(snippets: Snippet[], maxTokens: number): Snippet[] {
|
||||
const selected: Snippet[] = [];
|
||||
let usedTokens = 0;
|
||||
|
||||
for (const snippet of snippets) {
|
||||
if (usedTokens + (snippet.tokenCount ?? 0) > maxTokens) break;
|
||||
selected.push(snippet);
|
||||
usedTokens += snippet.tokenCount ?? 0;
|
||||
}
|
||||
for (const snippet of snippets) {
|
||||
if (usedTokens + (snippet.tokenCount ?? 0) > maxTokens) break;
|
||||
selected.push(snippet);
|
||||
usedTokens += snippet.tokenCount ?? 0;
|
||||
}
|
||||
|
||||
return selected;
|
||||
return selected;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -215,6 +214,7 @@ Default token budget: 10,000 tokens (~7,500 words) — enough for ~20 medium sni
|
||||
## CORS Configuration
|
||||
|
||||
All API routes include:
|
||||
|
||||
```
|
||||
Access-Control-Allow-Origin: *
|
||||
Access-Control-Allow-Methods: GET, POST, PATCH, DELETE, OPTIONS
|
||||
|
||||
Reference in New Issue
Block a user