1 | import * as bcrypt from "bcrypt-nodejs";
|
2 | import * as crypto from "crypto";
|
3 | import * as mongoose from "mongoose";
|
4 | import { ObjectId } from "mongodb";
|
5 |
|
6 | const sourceSchema = new mongoose.Schema({
|
7 | Endpoint: { type: String, unique: true },
|
8 | Interval: { type: Number, default: 60 * 1000 },
|
9 | IsActive: { type: Boolean, default: false },
|
10 | Thresholds: [
|
11 | {
|
12 | Name: { type: String },
|
13 | Formula: { type: String },
|
14 | Message: { type: String },
|
15 | Type: { type: String, enum: ["goal", "critical"], default: "critical" },
|
16 | ComputedFormula: { type: String }
|
17 | }
|
18 | ]
|
19 | }, { timestamps: true });
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | sourceSchema.pre("save", function save(next) {
|
25 | const source: any = this;
|
26 | if (!source.Thresholds) source.Thresholds = [];
|
27 | next();
|
28 | });
|
29 |
|
30 | const Source = mongoose.model("Source", sourceSchema);
|
31 |
|
32 | export { Source };
|
33 |
|