
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
@context-action/core
Advanced tools
Type-safe action pipeline management library for JavaScript/TypeScript applications.
npm install @context-action/core dotenv
# Copy sample configuration
cp .env.sample .env
# Quick setup for maximum debugging detail
echo "NODE_ENV=development" >> .env
echo "CONTEXT_ACTION_TRACE=true" >> .env
echo "CONTEXT_ACTION_DEBUG=true" >> .env
echo "CONTEXT_ACTION_LOGGER_NAME=MyApp" >> .env
// Load environment variables first
import 'dotenv/config';
import { ActionRegister } from '@context-action/core';
// Define your action types
interface MyActions {
increment: void;
setCount: number;
updateUser: { id: string; name: string };
}
// Create action register
const actions = new ActionRegister<MyActions>();
// Register handlers
actions.register('increment', (_, controller) => {
console.log('Increment called');
// Handler automatically continues to next handler
});
actions.register('setCount', (count, controller) => {
console.log(`Setting count to: ${count}`);
// Handler automatically continues to next handler
});
// Dispatch actions
await actions.dispatch('increment');
await actions.dispatch('setCount', 42);
| Variable | Description | Default | Max Detail |
|---|---|---|---|
CONTEXT_ACTION_TRACE | Enable detailed trace logging | false | true |
CONTEXT_ACTION_DEBUG | Enable debug mode | false | true |
CONTEXT_ACTION_LOG_LEVEL | Set specific log level (TRACE, DEBUG, INFO, WARN, ERROR, NONE) | ERROR | TRACE |
CONTEXT_ACTION_LOGGER_NAME | Custom logger name | ActionRegister | YourAppName |
NODE_ENV | Auto-configure logging (development = DEBUG, production = ERROR) | - | development |
💡 Tip: For maximum debugging detail, set all variables in the "Max Detail" column.
actions.register('myAction', handler, {
priority: 10, // Higher priority executes first
blocking: true, // Wait for async handlers
once: true, // Remove after first execution
condition: () => shouldRun, // Conditional execution
id: 'my-handler' // Custom handler ID
});
actions.register('validate', (data, controller) => {
if (!data.isValid) {
controller.abort('Validation failed');
return;
}
// Modify data for next handlers
controller.modifyPayload(data => ({ ...data, validated: true }));
// Handler automatically continues to next handler
});
actions.on('action:start', ({ action, payload }) => {
console.log(`Starting ${action}`, payload);
});
actions.on('action:complete', ({ action, metrics }) => {
console.log(`Completed ${action} in ${metrics.executionTime}ms`);
});
For the most comprehensive debugging experience, use this .env configuration:
# .env - Maximum detail logging configuration
NODE_ENV=development
CONTEXT_ACTION_TRACE=true
CONTEXT_ACTION_DEBUG=true
CONTEXT_ACTION_LOGGER_NAME=DetailedApp
# This configuration will show:
# - Every function call and return
# - Handler registration and execution details
# - Pipeline flow and state changes
# - Payload modifications and conditions
# - Performance metrics and timing
# - Error details and stack traces
# Development - Balanced detail
NODE_ENV=development
CONTEXT_ACTION_DEBUG=true
CONTEXT_ACTION_LOGGER_NAME=DevApp
# Production Debug - Errors only with context
NODE_ENV=production
CONTEXT_ACTION_LOG_LEVEL=ERROR
CONTEXT_ACTION_DEBUG=true
CONTEXT_ACTION_LOGGER_NAME=ProdApp
# Issue Investigation - Specific level
CONTEXT_ACTION_LOG_LEVEL=DEBUG
CONTEXT_ACTION_DEBUG=true
CONTEXT_ACTION_LOGGER_NAME=InvestigationSession
After setting up your .env file, test that maximum detail logging is working:
# Create a quick test file
echo "import 'dotenv/config';
import { ActionRegister } from '@context-action/core';
const actions = new ActionRegister();
actions.register('test', (payload, controller) => {
console.log('Handler executed:', payload);
// Handler automatically continues to next handler
});
await actions.dispatch('test', { message: 'Hello!' });" > test-logging.js
# Run the test
node test-logging.js
You should see detailed TRACE and DEBUG output if configured correctly.
Not seeing trace output?
Check dependencies: Make sure dotenv is installed
npm install dotenv
# or
pnpm install dotenv
Verify .env file: Confirm your .env file exists and has the correct settings
cat .env
# Should show: CONTEXT_ACTION_TRACE=true
Check import order: dotenv/config must be imported first
import 'dotenv/config'; // MUST be first
import { ActionRegister } from '@context-action/core';
Rebuild if needed: After installing dotenv, rebuild the project if using a bundler
For detailed debugging information, see TRACE_LOGGING.md.
Main class for managing action pipelines.
register<K>(action, handler, config?) - Register action handlerdispatch<K>(action, payload?) - Dispatch action through pipelinegetHandlerCount(action) - Get number of handlers for actionhasHandlers(action) - Check if action has handlersclearAction(action) - Remove all handlers for actionclearAll() - Remove all handlerson(event, handler) - Add event listenerinterface ActionRegisterConfig {
logger?: Logger; // Custom logger implementation
logLevel?: LogLevel; // Log filtering level
name?: string; // Logger name
debug?: boolean; // Enable debug mode
}
Full TypeScript support with compile-time type checking:
interface AppActions {
// Action without payload
reset: void;
// Action with payload
setUser: { id: string; name: string };
// Action with optional payload
navigate: string | undefined;
}
const actions = new ActionRegister<AppActions>();
// ✅ Type-safe dispatch
await actions.dispatch('reset');
await actions.dispatch('setUser', { id: '1', name: 'John' });
// ❌ TypeScript error - missing payload
await actions.dispatch('setUser');
// ❌ TypeScript error - wrong payload type
await actions.dispatch('setUser', 'invalid');
Apache-2.0
See the main repository for contribution guidelines.
FAQs
Type-safe action pipeline management library for JavaScript/TypeScript
The npm package @context-action/core receives a total of 4 weekly downloads. As such, @context-action/core popularity was classified as not popular.
We found that @context-action/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.