id | title | description |
---|---|---|
resolve-context |
ReSolve Context |
The 'resolve' context object is available to an API handler function through its request (req) argument. This object implements a communication layer between an API handler and the reSolve framework. |
:::info TypeScript Support
A reSolve context object has an associated TypeScript type:
- Type Name -
UserBackendResolve
- Package -
@resolve-js/runtime-base
:::
The resolve
context object is available to an API handler function through its request (req
) argument. This object implements a communication layer between an API handler and the reSolve framework.
The resolve
context object exposes the following API:
Field Name | Description |
---|---|
uploader |
Exposes the file upload API. |
eventstoreAdapter |
Exposes the event store adapter API. |
performanceTracer |
Exposes the performance tracer API. |
monitoring |
Exposes the monitoring API. |
Function Name | Description |
---|---|
executeCommand |
Executes a command on the server side. |
executeQuery |
Queries a read model or view model. |
Executes a command on the server side.
const myApiHandler = async (req, res) => {
const { resolve } = req
try {
const result = await resolve.executeCommand({
type: 'addItem',
aggregateName: 'MyItems',
aggregateId: uuid(),
payload: { name: itemName },
})
...
} catch (e) {
...
}
}
Argument Name | Type | Description |
---|---|---|
command |
A command object. | Describes a command to execute. |
A promise
that resolves to a command result object.
const myApiHandler = async (req, res) => {
const { resolve } = req
try {
const result = await resolve.executeQuery({
modelName: 'MyList',
resolverName: 'all',
})
...
} catch (e) {
...
}
}
Argument Name | Type | Description |
---|---|---|
query |
A read model query or view model query object. | Describes a query to execute. |
A promise
that resolves to a read model query result or view model query result depending on the query object's type.
Constant Name | Type | Description |
---|---|---|
applicationName |
string |
The reSolve application's name as specified in package.json . |
distDir |
string |
The path to the WebPack dist directory within the application. |
jwtCookie |
object |
An object that contains JWT cookie settings as specified in the application configuration. |
rootPath |
string |
The application's root URL path. |
staticDir |
string |
The path to a directory that contains static files. |
staticPath |
string |
The base URL path for static file URLs. |