Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "8"
- "24"

cache:
yarn: true
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
[![Build Status](https://travis-ci.org/erickjth/simple-command-bus.png?branch=master)](https://travis-ci.org/erickjth/simple-command-bus)
[![codecov](https://codecov.io/gh/erickjth/simple-command-bus/branch/master/graph/badge.svg)](https://codecov.io/gh/erickjth/simple-command-bus)


Simple Command Bus Implementation for NodeJS.
It is majorly inspired by Tactician Command Bus for PHP https://tactician.thephpleague.com/

## Requirements
This project requires nodejs 8 or higher.
This project requires nodejs 24 or higher.

## Install
### NPM
Expand Down
90 changes: 90 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
declare class Command {}

declare class Middleware {
execute(command: any, next: (...args: any[]) => any): any;
}

declare class CommandBus {
constructor(middlewares?: Middleware[]);
getMiddlewareStack(): Middleware[];
handle(command: any): any;
}

declare function CreateCommandBusProxy(commandBus: CommandBus, commandsDir: string): any;

declare class InvalidCommandException extends Error {
static forCommand(command?: any): never;
}

declare class InvalidMiddlewareException extends Error {
static forMiddleware(middleware?: any): never;
}

declare class InvalidHandlerMethodException extends Error {
static forMethod(method?: any): never;
}

declare class MissingHandlerException extends Error {
static forCommand(commandName?: string): never;
}

declare class CommandNameExtractor {
extractName(command: any): string;
}

declare class ClassNameExtractor extends CommandNameExtractor {}

declare class MethodNameInflector {
inflect(commandName: string, handler: any): string;
}

declare class HandleInflector extends MethodNameInflector {
constructor(methodName?: string);
}

declare class HandleClassNameInflector extends MethodNameInflector {}

declare class HandlerLocator {
getHandlerForCommand(commandName: string): any;
}

declare class InMemoryLocator extends HandlerLocator {
constructor(handlers?: Record<string, any>);
}

declare class NamespaceHandlerLocator extends HandlerLocator {
constructor(handlersPath: string);
}

declare class CommandHandlerMiddleware extends Middleware {
constructor(commandNameExtractor?: CommandNameExtractor, handlerLocator?: HandlerLocator, methodNameInflector?: MethodNameInflector);
set commandNameExtractor(v: CommandNameExtractor);
set handlerLocator(v: HandlerLocator);
set methodNameInflector(v: MethodNameInflector);
}

declare class LoggerMiddleware extends Middleware {
constructor(logger: any);
execute(command: any, next: (...args: any[]) => any): any;
}

export default CommandBus;
export {
CommandBus,
Middleware,
Command,
CreateCommandBusProxy,
InvalidMiddlewareException,
InvalidCommandException,
InvalidHandlerMethodException,
MissingHandlerException,
CommandHandlerMiddleware,
CommandNameExtractor,
MethodNameInflector,
HandlerLocator,
LoggerMiddleware,
ClassNameExtractor,
HandleInflector,
InMemoryLocator,
NamespaceHandlerLocator
};
17 changes: 0 additions & 17 deletions lib/Command.js

This file was deleted.

70 changes: 0 additions & 70 deletions lib/CommandBus.js

This file was deleted.

14 changes: 0 additions & 14 deletions lib/CommandInterface.js

This file was deleted.

58 changes: 0 additions & 58 deletions lib/CreateCommandBusProxy.js

This file was deleted.

34 changes: 0 additions & 34 deletions lib/Middleware.js

This file was deleted.

29 changes: 0 additions & 29 deletions lib/exceptions/InvalidCommand.js

This file was deleted.

29 changes: 0 additions & 29 deletions lib/exceptions/InvalidCommandException.js

This file was deleted.

Loading