@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.
@@ -134,6 +134,7 @@ module.exports = fp(async (fastify, options) => {
134
134
  type: 'object',
135
135
  properties: {
136
136
  id: { type: 'string' },
137
+ type: { type: 'string' },
137
138
  currentPage: { type: 'number', default: 1 },
138
139
  perPage: { type: 'number', default: 10 }
139
140
  }
@@ -15,6 +15,10 @@ module.exports = ({ DataTypes, options }) => {
15
15
  type: DataTypes.JSON,
16
16
  comment: '调用参数'
17
17
  },
18
+ type: {
19
+ type: DataTypes.STRING,
20
+ comment: '调用类型'
21
+ },
18
22
  status: {
19
23
  type: DataTypes.ENUM('success', 'failed'),
20
24
  comment: '调用返回状态'
@@ -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',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-webhook",
3
- "version": "0.1.3-alpha.4",
3
+ "version": "0.1.3-alpha.6",
4
4
  "description": "实现一个webhook功能.",
5
5
  "main": "index.js",
6
6
  "scripts": {