keryx 0.12.3 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/classes/Connection.ts +15 -12
- package/package.json +1 -1
package/classes/Connection.ts
CHANGED
|
@@ -100,6 +100,7 @@ export class Connection<
|
|
|
100
100
|
let error: TypedError | undefined;
|
|
101
101
|
|
|
102
102
|
let action: Action | undefined;
|
|
103
|
+
let formattedParams: Record<string, unknown> | undefined;
|
|
103
104
|
try {
|
|
104
105
|
action = this.findAction(actionName);
|
|
105
106
|
if (!action) {
|
|
@@ -112,7 +113,7 @@ export class Connection<
|
|
|
112
113
|
// load the session once, if it hasn't been loaded yet
|
|
113
114
|
if (!this.sessionLoaded) await this.loadSession();
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
formattedParams = await this.formatParams(params, action);
|
|
116
117
|
|
|
117
118
|
for (const middleware of action.middleware ?? []) {
|
|
118
119
|
if (middleware.runBefore) {
|
|
@@ -145,17 +146,6 @@ export class Connection<
|
|
|
145
146
|
} else {
|
|
146
147
|
response = await action.run(formattedParams, this);
|
|
147
148
|
}
|
|
148
|
-
|
|
149
|
-
for (const middleware of action.middleware ?? []) {
|
|
150
|
-
if (middleware.runAfter) {
|
|
151
|
-
const middlewareResponse = await middleware.runAfter(
|
|
152
|
-
formattedParams,
|
|
153
|
-
this,
|
|
154
|
-
);
|
|
155
|
-
if (middlewareResponse && middlewareResponse?.updatedResponse)
|
|
156
|
-
response = middlewareResponse.updatedResponse;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
149
|
} catch (e) {
|
|
160
150
|
loggerResponsePrefix = "ERROR";
|
|
161
151
|
error =
|
|
@@ -166,6 +156,19 @@ export class Connection<
|
|
|
166
156
|
type: ErrorType.CONNECTION_ACTION_RUN,
|
|
167
157
|
originalError: e,
|
|
168
158
|
});
|
|
159
|
+
} finally {
|
|
160
|
+
if (action && formattedParams) {
|
|
161
|
+
for (const middleware of action.middleware ?? []) {
|
|
162
|
+
if (middleware.runAfter) {
|
|
163
|
+
const middlewareResponse = await middleware.runAfter(
|
|
164
|
+
formattedParams,
|
|
165
|
+
this,
|
|
166
|
+
);
|
|
167
|
+
if (middlewareResponse && middlewareResponse?.updatedResponse)
|
|
168
|
+
response = middlewareResponse.updatedResponse;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
169
172
|
}
|
|
170
173
|
|
|
171
174
|
const duration = new Date().getTime() - reqStartTime;
|