@kne/fastify-webhook 0.1.3-alpha.4 → 0.1.3-alpha.5
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,12 @@ 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, type }
|
|
72
72
|
},
|
|
73
73
|
limit: perPage,
|
|
74
74
|
offset: (currentPage - 1) * perPage
|
|
@@ -133,6 +133,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
133
133
|
rawBody,
|
|
134
134
|
query
|
|
135
135
|
},
|
|
136
|
+
type,
|
|
136
137
|
status: 'failed',
|
|
137
138
|
startTime,
|
|
138
139
|
endTime: new Date()
|
|
@@ -144,6 +145,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
144
145
|
const result = await options.hooks[currentWebhook.type]({ input });
|
|
145
146
|
await models.invocation.create({
|
|
146
147
|
input,
|
|
148
|
+
type,
|
|
147
149
|
result,
|
|
148
150
|
webhookClientId: currentWebhook.id,
|
|
149
151
|
status: 'success',
|
|
@@ -154,6 +156,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
154
156
|
} catch (e) {
|
|
155
157
|
await models.invocation.create({
|
|
156
158
|
input,
|
|
159
|
+
type,
|
|
157
160
|
result: e.toString(),
|
|
158
161
|
webhookClientId: currentWebhook.id,
|
|
159
162
|
status: 'failed',
|