forked from Prompt-Hash-Stellar/prompt-hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebhookDeliveryLog.ts
More file actions
63 lines (59 loc) · 1.26 KB
/
Copy pathWebhookDeliveryLog.ts
File metadata and controls
63 lines (59 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import mongoose from "mongoose";
const webhookDeliveryLogSchema = new mongoose.Schema(
{
deliveryId: {
type: String,
required: true,
unique: true,
index: true,
},
subscriptionId: {
type: mongoose.Schema.Types.ObjectId,
ref: "WebhookSubscription",
required: true,
index: true,
},
event: {
type: String,
required: true,
index: true,
},
url: {
type: String,
required: true,
},
status: {
type: String,
enum: ["pending", "success", "failed", "retrying"],
default: "pending",
index: true,
},
attempts: {
type: Number,
default: 0,
},
lastStatus: {
type: Number,
default: null,
},
lastError: {
type: String,
default: null,
},
nextRetryAt: {
type: Date,
default: null,
},
completedAt: {
type: Date,
default: null,
},
},
{ timestamps: true },
);
webhookDeliveryLogSchema.index({ event: 1, createdAt: -1 });
webhookDeliveryLogSchema.index({ subscriptionId: 1, createdAt: -1 });
const WebhookDeliveryLog =
mongoose.models.WebhookDeliveryLog ||
mongoose.model("WebhookDeliveryLog", webhookDeliveryLogSchema);
export default WebhookDeliveryLog;