Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@halcyon-agile/node-event-sourcing
Advanced tools
Readme
Opinionated OOP based node.js event sourcing library inspired by laravel-event-sourcing
Class that handles the business logic and stream of events of a specific item such as a single Product and Order.
Class that handles event after being fired
Class that handles the update to read table after event is fired
process.env.KAFKA_BROKERS = "localhost:9092,localhost:9093"; // default: localhost:9092
process.env.KAFKA_GROUP_ID = "group"; // default: example-group
interface Item {
productId: string | null;
quantity: number;
}
export default class CartItemAdded {
event = "CartItemAdded";
payload: Item = {
productId: null,
quantity: 0,
};
constructor(payload: Item) {
this.payload = payload;
}
}
import { AggregateRoot } from "@halcyon-agile/node-event-sourcing";
import CartItemAdded from "./Events/CartItemAdded";
interface Item {
productId: string;
quantity: number;
}
export default class CartAggregateRoot extends AggregateRoot {
public items: Item[] = [];
public snapshotIn = 0;
constructor() {
super();
}
public async addItemToCart(item: Item): Promise<void> {
await this.createEvent(new CartItemAdded(item));
}
public async applyCartItemAdded(item: Item): Promise<void> {
const existingItem = this.items.find((i) => i.productId === item.productId);
if (existingItem) {
existingItem.quantity = existingItem.quantity + item.quantity;
} else {
this.items.push(item);
}
}
public async applySnapshot(currentState: { items: Item[] }): Promise<void> {
this.items = currentState.items;
}
}
import { Listener } from "@halcyon-agile/node-event-sourcing";
export default CartItemAddedListener implements Listener {
public async handle() {
// ...
}
}
import { Projector } from "@halcyon-agile/node-event-sourcing";
export default class HotProductsProjector implements Projector {
public async onCartItemAdded() {
// ...
}
}
import { Runner } from "@halcyon-agile/node-event-sourcing";
import * as path from "path";
Runner.registerListeners([path.resolve("./Listeners/CartListener")]);
Runner.registerProjectors([path.resolve("./Projectors/HotProductsProjector")]);
Runner.run()
.then(() => {
console.log("Event Sourcing is running...");
})
.catch((error) => {
console.log(error.message);
});
const Publisher = require("@halcyon-agile/node-event-sourcing/Publisher");
Publisher.run();
node poll-publisher.js
Upload the @halcyon-agile/node-event-sourcing/lambda-event-publisher.zip in AWS Lambda and use that lambda function as a DynamoDB stream source. Make sure that the Lambda connects to Kafka server.
Dead letter queue
Circuit breaker
Distributed circuit breaker
Immediate retry
Exponential Backoff
If you can make it fail fast, do it instead of using exponential backoff or dead letter queues.
const Replay = require("@halcyon-agile/node-event-sourcing/ReplayEvents");
// Replay all events and use all existing projectors
Replay.run();
// Replay specific projectors and event
Replay.run(
[path.resolve("./Projectors/HotProductsProjector")],
["CartItemAdded"]
);
node replay-events.js
node
FAQs
> Opinionated OOP based node.js event sourcing library inspired by laravel-event-sourcing
The npm package @halcyon-agile/node-event-sourcing receives a total of 18 weekly downloads. As such, @halcyon-agile/node-event-sourcing popularity was classified as not popular.
We found that @halcyon-agile/node-event-sourcing demonstrated a not healthy version release cadence and project activity because the last version was released 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.