
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
@codespiral/facts-rest
Advanced tools
The REST API data store provides a generic interface for working with various REST API patterns. It supports multiple configurations to handle different API designs.
The REST API data store provides a generic interface for working with various REST API patterns. It supports multiple configurations to handle different API designs.
Many REST APIs include the primary key in the URL path instead of query parameters:
const api = await makeRelREST({
baseUrl: "https://api.example.com/v1",
features: {
primaryKeyInPath: true,
},
});
const users = api.rel("users", {
restPrimaryKey: "id", // Specifies which field is the primary key
});
// This will generate: GET /users/123 instead of /users?id=123
users({ id: 123, name: $.name });
For complex URL patterns, you can provide a custom URL builder:
const api = await makeRelREST({
baseUrl: "https://api.example.com",
features: {
urlBuilder: (table, primaryKey, primaryKeyValue) => {
if (primaryKey && primaryKeyValue) {
return `https://api.example.com/${table}/${primaryKeyValue}/details`;
}
return `https://api.example.com/${table}`;
},
},
});
Some APIs don't support comma-separated values for IN operations. When disabled, multiple requests are made:
const api = await makeRelREST({
baseUrl: "https://api.example.com",
features: {
supportsInOperator: false, // Will make separate requests for each value
},
});
// This will make 3 separate requests instead of one with ?id=1,2,3
users({ id: [1, 2, 3], name: $.name });
Some APIs don't support field selection. When disabled, the fields parameter is not sent:
const api = await makeRelREST({
baseUrl: "https://api.example.com",
features: {
supportsFieldSelection: false, // Won't send ?fields=name,email
},
});
For APIs with non-standard query parameter formats:
const api = await makeRelREST({
baseUrl: "https://api.example.com",
features: {
queryParamFormatter: (column, operator, value) => {
if (operator === "gt") {
return { key: `${column}_greater_than`, value: String(value) };
}
if (operator === "like") {
return { key: `search_${column}`, value: String(value) };
}
return { key: column, value: String(value) };
},
},
});
interface RestDataStoreConfig {
baseUrl: string;
apiKey?: string;
timeout?: number;
headers?: Record<string, string>;
pagination?: {
limitParam?: string;
offsetParam?: string;
maxPageSize?: number;
};
features?: {
/** Whether to include primary key in URL path instead of query params */
primaryKeyInPath?: boolean;
/** Whether API supports comma-separated values for IN operations */
supportsInOperator?: boolean;
/** Whether API supports field selection via query params */
supportsFieldSelection?: boolean;
/** Custom URL builder for different API patterns */
urlBuilder?: (
table: string,
primaryKey?: string,
primaryKeyValue?: any,
) => string;
/** Custom query parameter formatter */
queryParamFormatter?: (
column: string,
operator: string,
value: any,
) => { key: string; value: string };
};
}
See src/test/rest-test.ts for complete examples of different REST API patterns.
FAQs
The REST API data store provides a generic interface for working with various REST API patterns. It supports multiple configurations to handle different API designs.
We found that @codespiral/facts-rest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.