chowbea-axios
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

  1. Creates api.config.toml with your settings
  2. Installs axios as a project dependency
  3. Adds npm scripts (api:fetch, api:watch, etc.)
  4. Generates client files (api.client.ts, api.instance.ts, etc.)
  5. Optionally sets up concurrent dev script (api:watch + your dev server)
  6. Runs initial fetch (if endpoint is not localhost)

Interactive Prompts

When you run init, you'll be asked:

  1. OpenAPI spec endpoint URL

    • Default: http://localhost:3000/docs/swagger/json
  2. Output folder location

    • Default: app/services/api
  3. Package manager

    • Auto-detected from lockfile, or choose manually
  4. Concurrent dev script (optional)

    • Combines api:watch with your existing dev scripts

Flags

FlagDescriptionDefault
--force, -fSkip all confirmations and overwrite everythingfalse
--skip-scriptsSkip adding npm scripts to package.jsonfalse
--skip-clientSkip generating client filesfalse
--skip-concurrentSkip setting up concurrent dev scriptfalse
--base-url-envEnvironment variable name for base URLVITE_API_URL
--token-keylocalStorage key for auth tokenauth-token
--with-credentialsInclude credentials (cookies) in requeststrue
--no-with-credentialsDisable credentials in requests-
--timeoutRequest timeout in milliseconds30000
-q, --quietSuppress non-error outputfalse
-v, --verboseShow detailed outputfalse

Examples

Basic Setup

chowbea-axios init

Non-Interactive Setup

chowbea-axios init --force

Custom Instance Configuration

chowbea-axios init \
  --base-url-env "NEXT_PUBLIC_API_URL" \
  --token-key "session-token" \
  --timeout 60000

Skip Client Generation

# Only create config and scripts, no client files
chowbea-axios init --skip-client

Generated 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:

package.json
{
  "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:

  1. Start your API server (if using localhost endpoint)
  2. Run chowbea-axios fetch to generate types
  3. Import api from your client file and start making typed requests

On this page