shiftapi
v0.0.42
Published
CLI and codegen for shiftapi – fully-typed TypeScript clients from Go servers
Downloads
353
Readme
shiftapi
CLI and codegen core for ShiftAPI. Extracts the OpenAPI spec from your Go server and generates a fully-typed TypeScript client. Used standalone or as the foundation for @shiftapi/vite-plugin and @shiftapi/next.
Installation
npm install -D shiftapi
# or
pnpm add -D shiftapiSetup
Create a shiftapi.config.ts in your project root:
import { defineConfig } from "shiftapi";
export default defineConfig({
server: "./cmd/server",
});CLI Usage
shiftapi prepareThis will:
- Find your
shiftapi.config.ts(searching upward from cwd) - Run your Go server to extract the OpenAPI 3.1 spec
- Generate TypeScript types via
openapi-typescript - Write
.shiftapi/client.d.tsand.shiftapi/client.js - Patch
tsconfig.jsonwith the required path mapping
Typically used in a postinstall script:
{
"scripts": {
"postinstall": "shiftapi prepare"
}
}Config Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| server | string | (required) | Path to the Go server entry point (e.g. "./cmd/server") |
| baseUrl | string | "/" | Base URL for the generated API client |
| url | string | "http://localhost:8080" | Go server address (used by the Vite/Next.js plugins for dev proxy) |
License
MIT
