@mcfarljw/capawesome-cloud
v0.1.1
Published
A typed API client for the Capawesome Cloud
Readme
@mcfarljw/capawesome-cloud
Usage
Install the package:
npx nypm install @mcfarljw/capawesome-cloud
Create a client:
import { createCapawesomeClient } from "@mcfarljw/capawesome-cloud";
const client = createCapawesomeClient({
token: process.env.CAPAWESOME_TOKEN,
});Call endpoints with typed path, query, and body options inferred from the
OpenAPI-generated types in src/types/capawesome.ts:
const apps = await client.get("/v1/apps", {
query: { limit: "20" },
});
await client.post("/v1/apps/{appId}/channels", {
path: { appId: "app_123" },
body: { name: "production" },
});Responses currently default to unknown because the generated OpenAPI operation
types expose responses: never. You can provide a response type when you call
the client:
const app = await client.get<{ data: { id: string; name: string } }>("/v1/apps/{appId}", {
path: { appId: "app_123" },
});You can also use the generic request method if you prefer passing an explicit
HTTP method:
const builds = await client.request("get", "/v1/apps/{appId}/builds", {
path: { appId: "app_123" },
query: { limit: "10" },
});Development
- Clone this repository
- Install latest LTS version of Node.js
- Enable Corepack using
corepack enable - Install dependencies using
pnpm install - Run interactive tests using
pnpm dev
License
Published under the MIT license 💛.
