Build production-ready APIs with type-safe validation, service management, and CLI scaffolding
npm install katax-service-manager npm install -g katax-cli Get expert guidance for the entire Katax ecosystem directly in VS Code with our custom GitHub Copilot skill.
Download the SKILL.md file from the button below
Place it in ~/.claude/skills/katax-ecosystem/ (Claude Desktop) or your Copilot skills folder
Restart VS Code and invoke with @katax-ecosystem
// In VS Code with GitHub Copilot
// Type: @katax-ecosystem how do I set up Redis logging?
// The skill provides context-aware guidance:
import { Katax } from 'katax-service-manager';
await Katax.getInstance().init({
loadEnv: true,
logger: {
level: 'info',
transports: {
redis: {
host: process.env.REDIS_HOST || 'localhost',
port: parseInt(process.env.REDIS_PORT || '6379'),
streamKey: 'app-logs',
maxLen: 10000
}
}
}
}); npm install katax-core Type-safe schema validation
npm install katax-service-manager Runtime service container
npm install -g katax-cli Project generator tool
# Install CLI globally
npm install -g katax-cli
# Create new API project
katax init my-api
# Generate a CRUD endpoint
katax generate-crud products
# Start development
npm run dev import { k, type kataxInfer } from 'katax-core';
const createUserSchema = k.object({
name: k.string().minLength(2).maxLength(100),
email: k.email().corporate(),
age: k.number().min(18).max(100),
roles: k.array(k.enum(['admin', 'user', 'moderator'] as const)),
acceptedTerms: k.boolean().refine(val => val === true, {
message: 'Must accept terms'
})
});
// Type inference
type CreateUserData = kataxInfer<typeof createUserSchema>;
// In your Express handler
export async function createUser(req: Request, res: Response) {
const result = createUserSchema.safeParse(req.body);
if (!result.success) {
return res.status(400).json({ errors: result.issues });
}
// result.data is fully typed
const user = await database.createUser(result.data);
res.status(201).json(user);
} import { Katax } from 'katax-service-manager';
// Initialize once at app startup
await Katax.getInstance().init({
loadEnv: true, // Auto-load .env file
config: {
port: process.env.PORT || 3000,
env: 'production'
},
logger: {
level: 'info',
transports: {
redis: {
host: process.env.REDIS_HOST,
streamKey: 'app-logs'
}
}
},
database: {
type: 'postgresql',
host: process.env.DB_HOST,
port: parseInt(process.env.DB_PORT || '5432'),
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME
}
});
// Use anywhere in your app
const katax = Katax.getInstance();
katax.logger.info('Server starting');
const users = await katax.db.query('SELECT * FROM users');
// Graceful shutdown handled automatically
katax.onShutdown(async () => {
katax.logger.info('Cleaning up...');
await cleanupResources();
}); # Install CLI globally
npm install -g katax-cli
# Create new project with interactive prompts
katax init my-api
✓ Project name: my-api
✓ Validation: katax-core
✓ Database: PostgreSQL
✓ Auth: JWT
✓ WebSocket: Yes
# Generate CRUD endpoints
cd my-api
katax generate-crud products
✓ Created src/api/products/products.controller.ts
✓ Created src/api/products/products.handler.ts
✓ Created src/api/products/products.validator.ts
✓ Created src/api/products/products.routes.ts
✓ Updated src/router.ts
# Add custom endpoint
katax add-endpoint users/profile --method GET
# Generate OpenAPI documentation
katax generate-docs
# Start development
npm run dev
# Server running on http://localhost:3000 import { Request, Response } from 'express';
import { k, type kataxInfer } from 'katax-core';
import { Katax } from 'katax-service-manager';
// Validation schema
const createProductSchema = k.object({
name: k.string().minLength(3).maxLength(100),
price: k.number().min(0),
categoryId: k.number().integer(),
tags: k.array(k.string()).optional()
});
type CreateProductData = kataxInfer<typeof createProductSchema>;
// Handler
export async function createProduct(req: Request, res: Response) {
const katax = Katax.getInstance();
// Validate request body
const validation = createProductSchema.safeParse(req.body);
if (!validation.success) {
return res.status(400).json({ errors: validation.issues });
}
try {
// Use database service
const result = await katax.db.query(
'INSERT INTO products (name, price, category_id) VALUES ($1, $2, $3) RETURNING *',
[validation.data.name, validation.data.price, validation.data.categoryId]
);
// Log with service
katax.logger.info('Product created', { productId: result.rows[0].id });
// Broadcast via WebSocket
katax.ws?.emit('product:created', result.rows[0]);
return res.status(201).json(result.rows[0]);
} catch (error) {
katax.logger.error('Failed to create product', { error });
return res.status(500).json({ error: 'Internal server error' });
}
} k.string()
.minLength(3)
.maxLength(50)
.email()
.url()
.regex(/^[a-zA-Z]+$/) k.number()
.min(0)
.max(100)
.positive()
.integer() k.date()
.min('2024-01-01')
.max('2024-12-31')
.isFuture()
.isPast() k.email()
.domain('company.com')
.corporate()
.noPlus() k.array(k.string())
.minLength(1)
.maxLength(10)
.unique() k.file()
.image()
.maxSize(5 * 1024 * 1024)
.extensions(['.jpg'])