Commands
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, etc.) - Optionally sets up concurrent dev script (api:watch + your dev server)
- 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 |
--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 |
--base-url-env | Environment variable name for base URL | VITE_API_URL |
--token-key | localStorage key for auth token | auth-token |
--with-credentials | Include credentials (cookies) in requests | true |
--no-with-credentials | Disable credentials in requests | - |
--timeout | 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
chowbea-axios init --forceCustom Instance Configuration
chowbea-axios init \
--base-url-env "NEXT_PUBLIC_API_URL" \
--token-key "session-token" \
--timeout 60000Skip Client Generation
# Only create config and scripts, no client files
chowbea-axios init --skip-clientGenerated Files
After running init, your project will have:
api.config.toml
package.json
api.client.ts
api.instance.ts
api.error.ts
api.helpers.ts
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