
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
resolve-command
Advanced tools
Creates a function that handles commands in a reSolve application.
Provides a function to handle a command and send the generated event to an eventstore based on definitions of aggregates and their commands.
When initializing a command, pass the following arguments:
aggregates
Each aggregate can have optional property snapshotAdapter
for managing snapshots mechanism. If property had not been passed, snapshots are turned off by default.
Property snapshotAdapter
receives the adapter for loading and saving intermediate aggregate state.
After the command is initialized, you get a function that is used to send an event to the event store. It receives two arguments:
command
An object with the following fields:
aggregateId
- a unique aggregate id.aggregateName
- the name of aggregate that has to handle the command.type
- the command type.jwt
- non-verified actual JSON Web Token provided from client.Define a news handling aggregate (see the news-aggregate.js
file), use the resolve-command
library to execute the createNews
command and send the corresponding event to the specified event store. To see a read model handling events which this aggregate produces, refer to the resolve-query package documentation.
import createStorageLiteAdapter from 'resolve-eventstore-lite'
import createCommandExecutor from 'resolve-command'
import newsAggregate from './news-aggregate'
...
const aggregates = [newsAggregate]
const memoryStorage = createStorageLiteAdapter({ databaseFile: ':memory:' })
const executeCommand = createCommandExecutor({
aggregates
})
const event = await executeCommand({
aggregateId: 'aggregate-id',
aggregateName: 'news',
type: 'createNews',
payload: {
title: 'News',
userId: 'user-id',
text: 'News content'
}
})
import Immutable from 'seamless-immutable'
export default {
name: 'news',
projection: {
Init: () => Immutable({}),
NEWS_CREATED: (state, { payload: { userId } }) =>
state.merge({
createdAt: Date.now(),
createdBy: userId,
voted: [],
comments: {}
})
},
commands: {
createNews: (state, { payload: { title, link, userId, text } }) => {
if (state.createdAt) {
throw new Error('Aggregate already exists')
}
if (!title) {
throw new Error('Title is required')
}
if (!userId) {
throw new Error('UserId is required')
}
return {
type: 'NEWS_CREATED',
payload: {
title,
text,
link,
userId
}
}
}
}
}
FAQs
Creates a function that handles commands in a reSolve application.
The npm package resolve-command receives a total of 309 weekly downloads. As such, resolve-command popularity was classified as not popular.
We found that resolve-command demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.