vk generate
vk generate <subcommand> [options]vk g <subcommand> [options]vk g is a shorthand alias for vk generate.
Subcommands
Section titled “Subcommands”vk generate route <path>
Section titled “vk generate route <path>”Generate a new route handler file.
Options:
| Option | Description | Default |
|---|---|---|
-m, --method <method> | HTTP method (get, post, put, patch, delete) | get |
--scopes <scopes> | Required OAuth scopes (comma-separated) | none |
Convention:
src/routes/<path>/<method>.ts → <METHOD> /<path>Examples:
# GET /tasksvk g route tasks
# POST /tasks (authenticated)vk g route tasks -m post --scopes tasks.write
# DELETE /tasks/{id}vk g route tasks/[id] -m delete --scopes tasks.write
# PUT /users/{id}/profilevk g route users/[id]/profile -m put --scopes users.writeGenerated file (vk g route tasks -m post --scopes tasks.write):
/** * POST /tasks */
import { handler } from '@venturekit/runtime';
export const main = handler( async (body, ctx, logger) => { logger.info('POST /tasks', { requestId: ctx.requestId });
return { message: 'Hello from POST /tasks', }; }, { scopes: ['tasks.write'] });vk generate config <env>
Section titled “vk generate config <env>”Generate an environment config file.
Examples:
# Generate config/staging.tsvk g config staging
# Generate config/qa.tsvk g config qaThe generated config uses a sensible preset based on the environment name:
| Environment | Preset | Data Safety |
|---|---|---|
prod / production | medium | strict |
stage | micro | standard |
| Other | nano | relaxed |
Generated file (vk g config staging):
/** * Staging Environment Configuration */
import type { EnvConfigInput } from '@venturekit/core';
export const staging: EnvConfigInput = { preset: 'micro', dataSafety: 'standard',};vk generate openapi
Section titled “vk generate openapi”Generate an OpenAPI 3.1 spec from your routes directory.
Options:
| Option | Description | Default |
|---|---|---|
-o, --output <file> | Output file path | openapi.json |
--routes-dir <dir> | Routes directory | src/routes |
--title <title> | API title | project name from package.json |
--version <version> | API version | 1.0.0 |
--yaml | Output YAML instead of JSON | false |
Examples:
# Generate OpenAPI JSONvk g openapi
# Generate YAMLvk g openapi --yaml
# Custom outputvk g openapi -o docs/api-spec.json --title "My API"vk generate client
Section titled “vk generate client”Generate a typed TypeScript API client from an OpenAPI spec. This produces an HTTP client that calls your API via HTTP — useful for frontend apps and external consumers.
Options:
| Option | Description | Default |
|---|---|---|
-i, --input <file> | OpenAPI spec file | openapi.json |
-o, --output <file> | Output client file | src/client.ts |
Examples:
# Generate client from default specvk g client
# Custom input/outputvk g client -i docs/api-spec.json -o src/api.tsvk generate postman
Section titled “vk generate postman”Generate a Postman collection (v2.1) from your routes directory. Import the generated file into Postman to test your API.
Options:
| Option | Description | Default |
|---|---|---|
-o, --output <file> | Output file path | postman-collection.json |
--routes-dir <dir> | Routes directory | src/routes |
--title <title> | Collection title | project name from package.json |
--base-url <url> | Base URL for requests | http://localhost:3000 |
Examples:
# Generate Postman collectionvk g postman
# Custom base URL (e.g., deployed API)vk g postman --base-url https://abc123.execute-api.us-east-1.amazonaws.com
# Custom outputvk g postman -o docs/postman.json --title "My API"The generated collection:
- Groups requests into folders by resource (first path segment)
- Includes Content-Type and Accept headers
- Uses
{{baseUrl}}variable for easy environment switching in Postman - Adds empty JSON body for POST/PUT/PATCH requests