Skip to content

vk generate

Terminal window
vk generate <subcommand> [options]
vk g <subcommand> [options]

vk g is a shorthand alias for vk generate.

Generate a new route handler file.

Options:

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

Terminal window
# GET /tasks
vk 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}/profile
vk g route users/[id]/profile -m put --scopes users.write

Generated 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'] }
);

Generate an environment config file.

Examples:

Terminal window
# Generate config/staging.ts
vk g config staging
# Generate config/qa.ts
vk g config qa

The generated config uses a sensible preset based on the environment name:

EnvironmentPresetData Safety
prod / productionmediumstrict
stagemicrostandard
Othernanorelaxed

Generated file (vk g config staging):

/**
* Staging Environment Configuration
*/
import type { EnvConfigInput } from '@venturekit/core';
export const staging: EnvConfigInput = {
preset: 'micro',
dataSafety: 'standard',
};

Generate an OpenAPI 3.1 spec from your routes directory.

Options:

OptionDescriptionDefault
-o, --output <file>Output file pathopenapi.json
--routes-dir <dir>Routes directorysrc/routes
--title <title>API titleproject name from package.json
--version <version>API version1.0.0
--yamlOutput YAML instead of JSONfalse

Examples:

Terminal window
# Generate OpenAPI JSON
vk g openapi
# Generate YAML
vk g openapi --yaml
# Custom output
vk g openapi -o docs/api-spec.json --title "My API"

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:

OptionDescriptionDefault
-i, --input <file>OpenAPI spec fileopenapi.json
-o, --output <file>Output client filesrc/client.ts

Examples:

Terminal window
# Generate client from default spec
vk g client
# Custom input/output
vk g client -i docs/api-spec.json -o src/api.ts

Generate a Postman collection (v2.1) from your routes directory. Import the generated file into Postman to test your API.

Options:

OptionDescriptionDefault
-o, --output <file>Output file pathpostman-collection.json
--routes-dir <dir>Routes directorysrc/routes
--title <title>Collection titleproject name from package.json
--base-url <url>Base URL for requestshttp://localhost:3000

Examples:

Terminal window
# Generate Postman collection
vk g postman
# Custom base URL (e.g., deployed API)
vk g postman --base-url https://abc123.execute-api.us-east-1.amazonaws.com
# Custom output
vk 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