Installation
Requirements
Section titled “Requirements”- Node.js 20.18.2 or higher
- TypeScript 5.0 or higher (recommended)
Package Installation
Section titled “Package Installation”Install cmd-ipc using your preferred package manager:
npm install @coralstack/cmd-ipc valibotyarn add @coralstack/cmd-ipc valibotpnpm add @coralstack/cmd-ipc valibotbun add @coralstack/cmd-ipc valibotTypeScript Configuration
Section titled “TypeScript Configuration”cmd-ipc uses decorators for the @Command syntax. Enable decorators in your tsconfig.json:
{ "compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true }}Reflect Metadata
Section titled “Reflect Metadata”The decorator system requires reflect-metadata. Import it once at your application’s entry point:
// main.ts or index.tsimport 'reflect-metadata'
// Rest of your applicationimport { CommandRegistry } from '@coralstack/cmd-ipc'CLI Installation (Optional)
Section titled “CLI Installation (Optional)”cmd-ipc includes a CLI for generating schemas from remote services. It’s included in the main package:
# Generate TypeScript schema from a remote HTTP endpointnpx cmd-ipc generate-schema --url http://localhost:8787 --output ./src/api-schema.tsOr add it as a script in your package.json:
{ "scripts": { "generate-schema": "cmd-ipc generate-schema --url http://localhost:8787 --output ./src/generated/api-schema.ts --prefix api" }}Package Exports
Section titled “Package Exports”cmd-ipc provides multiple entry points:
// Main exports - CommandRegistry, Channels, Decoratorsimport { CommandRegistry, MessagePortChannel, HTTPChannel, Command, registerCommands,} from '@coralstack/cmd-ipc'
// Testing utilitiesimport { TestLogger } from '@coralstack/cmd-ipc/testing'