Skip to content

Commit 4dce4ec

Browse files
committed
feat(orap)!: the next fn of the middleware and the task object swap positions
1 parent fc4cbba commit 4dce4ec

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

packages/orap/examples/declarativeDemo/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function startDemo(options: ListenOptions, storeConfig?: any) {
4343
.key(toKey)
4444
.prefix('ora-stack:orap:demo:TransferTask:', 'ora-stack:orap:demo:Done-TransferTask:')
4545
.ttl({ taskTtl: 120000, doneTtl: 60000 })
46-
.use(CheckTransactionStatus)
46+
.use(CheckTransactionStatus(options.wsProvider))
4747
.handle(handleTask)
4848
// add another task
4949
.another()

packages/orap/src/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ function checkIsTaskRaplized(task: any): task is TaskRaplized {
88
export function getMiddlewareContext(...args: any[]) {
99
if (args.length && Array.isArray(args[0])) {
1010
const newArgs = args[0]
11-
const next = newArgs.at(-1) as NextFunction
12-
const task = newArgs.at(-2) as TaskRaplized
11+
const next = newArgs.at(-2) as NextFunction
12+
const task = newArgs.at(-1) as TaskRaplized
1313
const isTaskRaplized = checkIsTaskRaplized(task)
1414

1515
if (typeof next === 'function' && isTaskRaplized) {
@@ -20,8 +20,8 @@ export function getMiddlewareContext(...args: any[]) {
2020
}
2121
}
2222

23-
const next = args.at(-1) as NextFunction
24-
const task = args.at(-2) as TaskRaplized
23+
const next = args.at(-2) as NextFunction
24+
const task = args.at(-1) as TaskRaplized
2525
const isTaskRaplized = checkIsTaskRaplized(task)
2626

2727
if (typeof next !== 'function' || !isTaskRaplized)

packages/utils/src/common/fn.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ export function composeFns<T>(...beforeNextArgs: Array<any>) {
77
return Promise.resolve()
88

99
const realArgs = childArgs.length ? childArgs : args
10-
1110
const handle = handles[index]
12-
return Promise.resolve(handle(...realArgs, ...beforeNextArgs, (...args: Array<any>) => dispatch(index + 1, ...args)))
11+
return Promise.resolve(handle(...realArgs, (...args: Array<any>) => dispatch(index + 1, ...args), ...beforeNextArgs))
1312
}
1413

1514
return dispatch(0, ...args)

0 commit comments

Comments
 (0)