init
Initialize chowbea-axios in your project with full setup.
The init command provides interactive project setup. It creates your configuration, installs dependencies, generates client files, and optionally fetches your first spec.
Usage
chowbea-axios init [flags]What It Does
- Creates
api.config.tomlwith your settings - Installs axios as a project dependency
- Adds npm scripts (
api:fetch,api:watch, etc.) - Generates client files (
api.client.ts,api.instance.ts,api.error.ts,api.helpers.ts) - Optionally sets up concurrent dev script (api:watch + your dev server)
- Optionally scaffolds a hardened CI workflow at
.github/workflows/chowbea-axios-ci.yml - Optionally scaffolds the Vite codegen plugins (
--with-vite-plugins) for Surfaces and Side Panels - Runs initial fetch (if endpoint is not localhost)
Interactive Prompts
When you run init, you'll be asked:
-
OpenAPI spec endpoint URL
- Default:
http://localhost:3000/docs/swagger/json
- Default:
-
Output folder location
- Default:
app/services/api
- Default:
-
Package manager
- Auto-detected from lockfile, or choose manually
-
Concurrent dev script (optional)
- Combines api:watch with your existing dev scripts
Flags
| Flag | Description | Default |
|---|---|---|
--force, -f | Skip all confirmations and overwrite everything | false |
--non-interactive | Skip every prompt — requires --endpoint or --spec-file. Also auto-enabled when stdin isn't a TTY. | false |
--endpoint <url> | Spec source. Required (with --non-interactive) if --spec-file isn't set. | - |
--spec-file <path> | Local spec source. Alternative to --endpoint. | - |
--output-folder <path> | Override the output folder prompt | src/api |
--package-manager <pm> | Force a specific package manager (npm, pnpm, yarn, bun). Auto-detected from lockfile by default. | auto |
--skip-scripts | Skip adding npm scripts to package.json | false |
--skip-client | Skip generating client files | false |
--skip-concurrent | Skip setting up concurrent dev script | false |
--skip-workflow | Skip scaffolding the GitHub Actions workflow | false |
--with-vite-plugins | Scaffold the Vite codegen plugins (Surfaces & Side Panels) | false |
--base-url-env <var> | Environment variable name for base URL | API_BASE_URL |
--env-accessor <str> | How to access env vars in the generated client (process.env or import.meta.env) | process.env |
--auth-mode <mode> | Auth interceptor mode: bearer-localstorage, custom, or none | custom |
--token-key <key> | localStorage key for auth token (only used with bearer-localstorage) | auth-token |
--with-credentials | Include credentials (cookies) in requests | true |
--timeout <ms> | Request timeout in milliseconds | 30000 |
-q, --quiet | Suppress non-error output | false |
-v, --verbose | Show detailed output | false |
Examples
Basic Setup
chowbea-axios initNon-Interactive Setup (CI / project starters)
--non-interactive skips every prompt. You must supply a spec source via --endpoint or --spec-file:
chowbea-axios init --non-interactive \
--endpoint https://staging.example.com/openapi.json \
--output-folder src/api \
--package-manager npmForce Overwrite
# Overwrite existing files without prompting
chowbea-axios init --forceCustom Instance Configuration
chowbea-axios init \
--base-url-env "NEXT_PUBLIC_API_URL" \
--env-accessor "process.env" \
--auth-mode "bearer-localstorage" \
--token-key "session-token" \
--timeout 60000Skip Client Generation
# Only create config and scripts, no client files
chowbea-axios init --skip-clientWith Vite Plugins
# Scaffold surfaces & side-panels registries and add plugins to vite.config.ts
chowbea-axios init --with-vite-pluginsGenerated Files
After running init, your project will have:
The output folder is configurable via --output-folder or the interactive prompt — src/api is the default. The api.contracts.ts, api.types.ts, and api.operations.ts files inside _generated/ are written on the first fetch, not by init.
CI Workflow Template
By default, init scaffolds .github/workflows/chowbea-axios-ci.yml — a hardened workflow that re-fetches your spec on every PR and fails when the generated client is out of date. The template includes:
permissions: contents: read(default-deny)concurrencycancel-in-progress- Node 22 + npm cache (with commented variants for bun/pnpm/yarn)
- Pinned action SHAs
varsorsecretsfallback forSTAGING_API_ENDPOINT
Pass --skip-workflow to opt out.
Existing Setup Detection
If you already have chowbea-axios set up, init will detect existing files and ask before overwriting:
Existing setup detected:
- api.config.toml
- api.instance.ts
- api.client.ts
Continue with setup? (existing files may be modified) (Y/n)Use --force to skip this check.
Concurrent Dev Script
The init command can set up a script that runs api:watch alongside your dev server using concurrently:
{
"scripts": {
"dev:all": "concurrently --names 'api,dev' \"npm run api:watch\" \"npm run dev\""
}
}If you choose to set this up, init will automatically install concurrently as a dev dependency.
Next Steps
After init completes:
- Start your API server (if using localhost endpoint)
- Run
chowbea-axios fetchto generate types - Import
apifrom your client file and start making typed requests