@kne/fastify-webhook 0.1.3-alpha.4 → 0.1.3-alpha.6
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/libs/controllers/main.js
CHANGED
package/libs/services/main.js
CHANGED
|
@@ -63,12 +63,13 @@ module.exports = fp(async (fastify, options) => {
|
|
|
63
63
|
);
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
const invokeRecord = async ({ id, currentPage, perPage }) => {
|
|
66
|
+
const invokeRecord = async ({ id, type, currentPage, perPage }) => {
|
|
67
67
|
const { rows, count } = await models.invocation.findAndCountAll({
|
|
68
68
|
where: id
|
|
69
69
|
? { webhookClientId: id }
|
|
70
70
|
: {
|
|
71
|
-
webhookClientId: { [Op.is]: null }
|
|
71
|
+
webhookClientId: { [Op.is]: null },
|
|
72
|
+
type
|
|
72
73
|
},
|
|
73
74
|
limit: perPage,
|
|
74
75
|
offset: (currentPage - 1) * perPage
|
|
@@ -133,6 +134,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
133
134
|
rawBody,
|
|
134
135
|
query
|
|
135
136
|
},
|
|
137
|
+
type,
|
|
136
138
|
status: 'failed',
|
|
137
139
|
startTime,
|
|
138
140
|
endTime: new Date()
|
|
@@ -144,6 +146,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
144
146
|
const result = await options.hooks[currentWebhook.type]({ input });
|
|
145
147
|
await models.invocation.create({
|
|
146
148
|
input,
|
|
149
|
+
type,
|
|
147
150
|
result,
|
|
148
151
|
webhookClientId: currentWebhook.id,
|
|
149
152
|
status: 'success',
|
|
@@ -154,6 +157,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
154
157
|
} catch (e) {
|
|
155
158
|
await models.invocation.create({
|
|
156
159
|
input,
|
|
160
|
+
type,
|
|
157
161
|
result: e.toString(),
|
|
158
162
|
webhookClientId: currentWebhook.id,
|
|
159
163
|
status: 'failed',
|