@upsnap/strapi 1.0.0 → 1.0.2

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.
@@ -0,0 +1,1090 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const bootstrap = ({ strapi }) => {
4
+ };
5
+ const destroy = ({ strapi }) => {
6
+ };
7
+ const register = ({ strapi }) => {
8
+ };
9
+ const config = {
10
+ default: {},
11
+ validator() {
12
+ }
13
+ };
14
+ const contentTypes = {};
15
+ const controller = ({ strapi }) => ({
16
+ index(ctx) {
17
+ ctx.body = strapi.plugin("upsnap").service("service").getWelcomeMessage();
18
+ }
19
+ });
20
+ const BACKEND_URL = "https://api.upsnap.ai/v1";
21
+ const LIGHTHOUSE_CHECKS = ["performance", "accessibility", "bestPractices", "seo", "pwa"];
22
+ const service = ({ strapi }) => ({
23
+ getWelcomeMessage() {
24
+ return "Welcome to Strapi 🚀";
25
+ },
26
+ settingsStore: strapi.store({
27
+ type: "plugin",
28
+ name: "upsnap",
29
+ key: "settings"
30
+ }),
31
+ async getToken() {
32
+ const settings2 = await this.settingsStore.get();
33
+ return settings2?.token || null;
34
+ },
35
+ async makeBackendRequest(endpoint, options) {
36
+ const token = await this.getToken();
37
+ if (!token) {
38
+ return { error: "No token found in settings" };
39
+ }
40
+ const response = await fetch(`${BACKEND_URL}${endpoint}`, {
41
+ ...options,
42
+ headers: {
43
+ Authorization: `Bearer ${token}`,
44
+ "Content-Type": "application/json",
45
+ ...options.headers || {}
46
+ }
47
+ });
48
+ return response.json();
49
+ }
50
+ });
51
+ const settings = ({ strapi }) => ({
52
+ async get(ctx) {
53
+ const settings2 = await service({ strapi }).settingsStore.get();
54
+ ctx.body = {
55
+ token: settings2?.token ?? null,
56
+ primaryMonitorId: settings2?.primaryMonitorId ?? null
57
+ };
58
+ },
59
+ async set(ctx) {
60
+ const { token } = ctx.request.body;
61
+ const isValidData = await service({ strapi }).makeBackendRequest("/tokens/validate", {
62
+ method: "POST",
63
+ body: JSON.stringify({ token })
64
+ });
65
+ if (!isValidData?.data?.valid) {
66
+ ctx.body = { ok: false, error: "Invalid token" };
67
+ return;
68
+ }
69
+ const store = service({ strapi }).settingsStore;
70
+ const current = await store.get() || {};
71
+ await store.set({
72
+ value: {
73
+ ...current,
74
+ token
75
+ }
76
+ });
77
+ ctx.body = { ok: true };
78
+ },
79
+ async setPrimaryMonitorId(ctx) {
80
+ const { monitorId } = ctx.request.body;
81
+ const store = service({ strapi }).settingsStore;
82
+ const current = await store.get() || {};
83
+ await store.set({
84
+ value: {
85
+ ...current,
86
+ primaryMonitorId: monitorId
87
+ }
88
+ });
89
+ ctx.body = { ok: true };
90
+ },
91
+ async getPrimaryMonitorId(ctx) {
92
+ const settings2 = await service({ strapi }).settingsStore.get();
93
+ ctx.body = { primaryMonitorId: settings2?.primaryMonitorId };
94
+ }
95
+ });
96
+ function getMixedContentMessage(meta) {
97
+ if (!meta) return "Mixed content check completed";
98
+ const mixedCount = meta.mixedCount ?? 0;
99
+ if (mixedCount === 0) return "No mixed content found.";
100
+ if (mixedCount === 1) return "1 mixed content item detected.";
101
+ return `${mixedCount} mixed content items detected!`;
102
+ }
103
+ function buildSuccessResponse(raw) {
104
+ const meta = raw?.result?.details?.mixed_content?.meta || {};
105
+ raw?.result?.durationMs ?? null;
106
+ const mixedCount = meta?.mixedCount ?? 0;
107
+ let status = "success";
108
+ if (mixedCount > 0) status = "warning";
109
+ return {
110
+ status,
111
+ message: getMixedContentMessage(meta),
112
+ data: raw
113
+ };
114
+ }
115
+ const formatMessage = (message) => {
116
+ return message.charAt(0).toUpperCase() + message.slice(1);
117
+ };
118
+ function getStatusMessage(statusCode) {
119
+ if (statusCode === void 0 || statusCode === null) return "Status check completed";
120
+ if (statusCode >= 200 && statusCode < 300) return "All good";
121
+ if (statusCode >= 300 && statusCode < 400) return "Redirection detected, but reachable";
122
+ if (statusCode >= 400 && statusCode < 500) return "Client error detected";
123
+ if (statusCode >= 500) return "Server error detected";
124
+ return "Status check completed";
125
+ }
126
+ function buildReachabilitySuccessResponse(raw) {
127
+ const meta = raw?.result?.details?.uptime?.meta || null;
128
+ raw?.result?.durationMs ?? null;
129
+ return {
130
+ status: "success",
131
+ message: getStatusMessage(meta?.statusCode),
132
+ data: raw
133
+ };
134
+ }
135
+ function buildReachabilityErrorResponse(raw) {
136
+ const uptime = raw?.result?.details?.uptime || {};
137
+ const summary = raw?.result?.summary || {};
138
+ const errorMsg = uptime?.error ?? summary?.message ?? "Unknown error from healthcheck service";
139
+ return {
140
+ status: "error",
141
+ message: "Failed to get the reachability reports",
142
+ error: formatMessage(errorMsg),
143
+ data: raw
144
+ };
145
+ }
146
+ function getSecurityCertMessage(meta) {
147
+ if (!meta?.chain || !Array.isArray(meta.chain)) {
148
+ return "Security certificates check completed";
149
+ }
150
+ const leafCert = meta.chain.find((c) => c.depth === 0)?.info;
151
+ if (!leafCert) return "Unable to verify SSL certificate chain";
152
+ const { daysUntilExpiry, isExpired } = leafCert;
153
+ if (isExpired) {
154
+ return "Certificate has expired!";
155
+ }
156
+ if (daysUntilExpiry <= 0) {
157
+ return "Expires today.";
158
+ }
159
+ if (daysUntilExpiry <= 7) {
160
+ return `Expiring soon (in ${daysUntilExpiry} day${daysUntilExpiry > 1 ? "s" : ""})!`;
161
+ }
162
+ if (daysUntilExpiry <= 15) {
163
+ return `Expires in ${daysUntilExpiry} days. Consider renewing soon.`;
164
+ }
165
+ return `Valid for ${daysUntilExpiry} more day${daysUntilExpiry > 1 ? "s" : ""}.`;
166
+ }
167
+ function buildSslSuccessResponse(raw) {
168
+ const meta = raw?.result?.details?.ssl?.meta || {};
169
+ raw?.result?.durationMs ?? null;
170
+ const leafCert = meta?.chain?.find((c) => c.depth === 0)?.info;
171
+ const daysUntilExpiry = leafCert?.daysUntilExpiry ?? null;
172
+ const isExpired = leafCert?.isExpired ?? false;
173
+ let status = "success";
174
+ if (isExpired) {
175
+ status = "error";
176
+ } else if (daysUntilExpiry !== null && daysUntilExpiry <= 15) {
177
+ status = "warning";
178
+ }
179
+ return {
180
+ status,
181
+ message: getSecurityCertMessage(meta),
182
+ data: raw
183
+ };
184
+ }
185
+ function buildSslErrorResponse(raw) {
186
+ const sslDetails = raw?.result?.details?.ssl || {};
187
+ const summary = raw?.result?.summary || {};
188
+ const errorMsg = sslDetails?.error ?? summary?.message ?? "Unknown error from SSL check service";
189
+ return {
190
+ status: "error",
191
+ message: "Failed to get SSL certificate report",
192
+ error: errorMsg,
193
+ data: raw
194
+ };
195
+ }
196
+ function getDomainCheckMessage(meta) {
197
+ if (!meta) return "Domain check completed";
198
+ if (meta?.message) return meta.message;
199
+ const { domainExpired, domainExpiring, domainDays } = meta;
200
+ if (domainExpired) {
201
+ return "Domain has expired! Immediate renewal is required.";
202
+ }
203
+ if (domainExpiring) {
204
+ return "Domain is expiring soon! Please renew your registration.";
205
+ }
206
+ if (domainDays <= 7) {
207
+ return `Expiring in ${domainDays} day${domainDays > 1 ? "s" : ""}! Renew immediately.`;
208
+ }
209
+ if (domainDays <= 15) {
210
+ return `Expires in ${domainDays} days. Consider renewing soon.`;
211
+ }
212
+ if (domainDays <= 30) {
213
+ return `Valid for ${domainDays} more days. Renewal window approaching.`;
214
+ }
215
+ if (domainDays > 365) {
216
+ return "Renewed for more than a year.";
217
+ }
218
+ return "Domain is active and healthy.";
219
+ }
220
+ function buildDomainSuccessResponse(raw) {
221
+ const meta = raw?.result?.details?.domain?.meta || {};
222
+ raw?.result?.durationMs ?? null;
223
+ const domainExpired = meta?.domainExpired ?? false;
224
+ const domainExpiring = meta?.domainExpiring ?? false;
225
+ const domainDays = meta?.domainDays ?? null;
226
+ let status = "success";
227
+ if (domainExpired) {
228
+ status = "error";
229
+ } else if (domainExpiring || meta?.message || domainDays !== null && domainDays <= 30) {
230
+ status = "warning";
231
+ }
232
+ return {
233
+ status,
234
+ message: getDomainCheckMessage(meta),
235
+ data: raw
236
+ };
237
+ }
238
+ function buildDomainErrorResponse(raw) {
239
+ const domainDetails = raw?.result?.details?.domain || {};
240
+ const summary = raw?.result?.summary || {};
241
+ const errorMsg = domainDetails?.error ?? summary?.message ?? "Unknown error from domain check service";
242
+ return {
243
+ status: "error",
244
+ message: "Failed to get domain report",
245
+ error: formatMessage(errorMsg),
246
+ data: raw
247
+ };
248
+ }
249
+ function getLighthouseMessage(meta) {
250
+ if (!meta) return "Lighthouse audit completed";
251
+ const categories = ["performance", "accessibility", "bestPractices", "seo", "pwa"];
252
+ const lowScores = categories.filter(
253
+ (cat) => meta[cat]?.score !== void 0 && meta[cat]?.score < 50
254
+ );
255
+ const mediumScores = categories.filter((cat) => meta[cat]?.score >= 50 && meta[cat]?.score < 90);
256
+ if (lowScores.length > 0) return `Poor scores.`;
257
+ if (mediumScores.length > 0) return `Some scores could be improved.`;
258
+ return "Excellent.";
259
+ }
260
+ function buildLighthouseSuccessResponse(raw) {
261
+ const meta = raw?.result?.details?.lighthouse?.meta || {};
262
+ raw?.result?.durationMs ?? null;
263
+ const categories = LIGHTHOUSE_CHECKS;
264
+ const allScores = categories.map((cat) => meta[cat]?.score ?? null);
265
+ const minScore = Math.min(...allScores.filter((v) => v !== null));
266
+ let status = "success";
267
+ if (minScore < 50) status = "warning";
268
+ else if (minScore < 90) status = "warning";
269
+ return {
270
+ status,
271
+ message: getLighthouseMessage(meta),
272
+ data: raw
273
+ };
274
+ }
275
+ function buildLighthouseErrorResponse(raw) {
276
+ const lighthouseDetails = raw?.result?.details?.lighthouse || {};
277
+ const summary = raw?.result?.summary || {};
278
+ const errorMsg = lighthouseDetails?.error ?? summary?.message ?? "Unknown error from Lighthouse audit service";
279
+ return {
280
+ status: "error",
281
+ message: "Failed to get Lighthouse report",
282
+ error: formatMessage(errorMsg),
283
+ data: raw
284
+ };
285
+ }
286
+ function getBrokenLinksMessage(meta) {
287
+ if (!meta) return "Broken link check completed";
288
+ const { broken = 0, redirected = 0 } = meta;
289
+ if (broken === 0 && redirected === 0) return "No broken links!";
290
+ if (broken > 0) return `${broken} broken ${broken > 1 ? "links" : "link"} found.`;
291
+ if (redirected > 0)
292
+ return `${redirected} redirected ${redirected > 1 ? "links" : "link"} detected.`;
293
+ return "Scan completed with mixed results.";
294
+ }
295
+ function buildBrokenLinksSuccessResponse(raw) {
296
+ const meta = raw?.result?.details?.broken_links?.meta || null;
297
+ raw?.result?.durationMs ?? null;
298
+ const { broken = 0, redirected = 0 } = meta || {};
299
+ let status = "success";
300
+ if (broken > 0 || redirected > 0) {
301
+ status = "warning";
302
+ }
303
+ return {
304
+ status,
305
+ message: getBrokenLinksMessage(meta),
306
+ data: raw
307
+ };
308
+ }
309
+ function buildBrokenLinksErrorResponse(raw) {
310
+ const brokenLinks = raw?.result?.details?.broken_links || {};
311
+ const summary = raw?.result?.summary || {};
312
+ const errorMsg = brokenLinks?.error ?? summary?.message ?? "Unknown error from broken links check service";
313
+ return {
314
+ status: "error",
315
+ message: "Failed to get broken links report",
316
+ error: formatMessage(errorMsg),
317
+ data: raw
318
+ };
319
+ }
320
+ const monitor = ({ strapi }) => ({
321
+ async getById(ctx) {
322
+ const monitorId = ctx.params.id;
323
+ const token = await service({ strapi }).getToken();
324
+ const monitorResponse = await fetch(`${BACKEND_URL}/user/monitors/${monitorId}`, {
325
+ method: "GET",
326
+ headers: {
327
+ Authorization: `Bearer ${token}`,
328
+ "Content-Type": "application/json"
329
+ }
330
+ });
331
+ const monitor2 = await monitorResponse.json();
332
+ ctx.body = { monitor: monitor2 };
333
+ },
334
+ async get(ctx) {
335
+ const monitorsData = await service({ strapi }).makeBackendRequest(
336
+ `/user/monitors`,
337
+ {
338
+ method: "GET"
339
+ }
340
+ );
341
+ ctx.body = { monitorsData };
342
+ },
343
+ async getMonitorUptimeStats(ctx) {
344
+ const monitorId = ctx.params.id;
345
+ const { region } = ctx.query;
346
+ const uptimeStatsData = await service({ strapi }).makeBackendRequest(
347
+ `/user/monitors/${monitorId}/uptime-stats?uptime_stats_time_frames=day,week,month&region=${region}`,
348
+ {
349
+ method: "GET"
350
+ }
351
+ );
352
+ ctx.body = { uptimeStatsData };
353
+ },
354
+ async getMonitorHistogram(ctx) {
355
+ const monitorId = ctx.params.id;
356
+ const { region } = ctx.query;
357
+ const histogramData = await service({ strapi }).makeBackendRequest(
358
+ `/user/monitors/${monitorId}/histogram?region=${region}`,
359
+ {
360
+ method: "GET"
361
+ }
362
+ );
363
+ ctx.body = { histogramData };
364
+ },
365
+ async getHealthChecks(ctx) {
366
+ const { monitorUrl } = ctx.request.body;
367
+ const healthCheckData = await service({ strapi }).makeBackendRequest(`/healthcheck`, {
368
+ method: "POST",
369
+ headers: {
370
+ "X-Requested-From": "craft"
371
+ },
372
+ body: JSON.stringify({
373
+ url: monitorUrl,
374
+ checks: ["uptime", "ssl", "lighthouse", "domain", "broken_links", "mixed_content"],
375
+ strategy: "desktop",
376
+ force_fetch: false
377
+ })
378
+ });
379
+ ctx.body = { healthCheckData };
380
+ },
381
+ async getUptimeHealthCheck(ctx) {
382
+ const { monitorUrl } = ctx.request.body;
383
+ const uptimeHealthCheckData = await service({ strapi }).makeBackendRequest(
384
+ `/healthcheck`,
385
+ {
386
+ method: "POST",
387
+ headers: {
388
+ "X-Requested-From": "craft"
389
+ },
390
+ body: JSON.stringify({
391
+ url: monitorUrl,
392
+ checks: ["uptime"],
393
+ force_fetch: false
394
+ })
395
+ }
396
+ );
397
+ const summaryOk = uptimeHealthCheckData?.result?.summary?.ok;
398
+ const uptimeOk = uptimeHealthCheckData?.result?.details?.uptime?.ok;
399
+ if (summaryOk === false || uptimeOk === false) {
400
+ const errorResponse = buildReachabilityErrorResponse(uptimeHealthCheckData);
401
+ ctx.body = { uptimeHealthCheckData: errorResponse };
402
+ return;
403
+ }
404
+ ctx.body = { uptimeHealthCheckData: buildReachabilitySuccessResponse(uptimeHealthCheckData) };
405
+ },
406
+ async getSslHealthCheck(ctx) {
407
+ const { monitorUrl } = ctx.request.body;
408
+ const sslHealthCheckData = await service({ strapi }).makeBackendRequest(`/healthcheck`, {
409
+ method: "POST",
410
+ headers: {
411
+ "X-Requested-From": "craft"
412
+ },
413
+ body: JSON.stringify({
414
+ url: monitorUrl,
415
+ checks: ["ssl"],
416
+ force_fetch: false
417
+ })
418
+ });
419
+ const summaryOk = sslHealthCheckData?.result?.summary?.ok;
420
+ const sslOk = sslHealthCheckData?.result?.details?.ssl?.ok;
421
+ const sslError = sslHealthCheckData?.result?.details?.ssl?.error;
422
+ if ((summaryOk === false || sslOk === false) && sslError) {
423
+ ctx.body = { sslHealthCheckData: buildSslErrorResponse(sslHealthCheckData) };
424
+ return;
425
+ }
426
+ ctx.body = { sslHealthCheckData: buildSslSuccessResponse(sslHealthCheckData) };
427
+ },
428
+ async getDomainHealthCheck(ctx) {
429
+ const { monitorUrl } = ctx.request.body;
430
+ const domainHealthCheckData = await service({ strapi }).makeBackendRequest(
431
+ `/healthcheck`,
432
+ {
433
+ method: "POST",
434
+ headers: {
435
+ "X-Requested-From": "craft"
436
+ },
437
+ body: JSON.stringify({
438
+ url: monitorUrl,
439
+ checks: ["domain"],
440
+ force_fetch: false
441
+ })
442
+ }
443
+ );
444
+ const summaryOk = domainHealthCheckData?.result?.summary?.ok;
445
+ const domainOk = domainHealthCheckData?.result?.details?.domain?.ok;
446
+ const domainError = domainHealthCheckData?.result?.details?.domain?.error;
447
+ if ((summaryOk === false || domainOk === false) && domainError) {
448
+ ctx.body = { domainHealthCheckData: buildDomainErrorResponse(domainHealthCheckData) };
449
+ return;
450
+ }
451
+ ctx.body = { domainHealthCheckData: buildDomainSuccessResponse(domainHealthCheckData) };
452
+ },
453
+ async getLighthouseHealthCheck(ctx) {
454
+ const { monitorUrl, strategy } = ctx.request.body;
455
+ const lighthouseHealthCheckData = await service({ strapi }).makeBackendRequest(
456
+ `/healthcheck`,
457
+ {
458
+ method: "POST",
459
+ headers: {
460
+ "X-Requested-From": "craft"
461
+ },
462
+ body: JSON.stringify({
463
+ url: monitorUrl,
464
+ checks: ["lighthouse"],
465
+ strategy: strategy || "desktop",
466
+ force_fetch: false
467
+ })
468
+ }
469
+ );
470
+ const summaryOk = lighthouseHealthCheckData?.result?.summary?.ok;
471
+ const lighthouseOk = lighthouseHealthCheckData?.result?.details?.lighthouse?.ok;
472
+ const lighthouseError = lighthouseHealthCheckData?.result?.details?.lighthouse?.error;
473
+ if ((summaryOk === false || lighthouseOk === false) && lighthouseError) {
474
+ ctx.body = {
475
+ lighthouseHealthCheckData: buildLighthouseErrorResponse(lighthouseHealthCheckData)
476
+ };
477
+ return;
478
+ }
479
+ ctx.body = {
480
+ lighthouseHealthCheckData: buildLighthouseSuccessResponse(lighthouseHealthCheckData)
481
+ };
482
+ },
483
+ async getBrokenLinksHealthCheck(ctx) {
484
+ const { monitorUrl } = ctx.request.body;
485
+ const brokenLinksHealthCheckData = await service({ strapi }).makeBackendRequest(
486
+ `/healthcheck`,
487
+ {
488
+ method: "POST",
489
+ headers: {
490
+ "X-Requested-From": "craft"
491
+ },
492
+ body: JSON.stringify({
493
+ url: monitorUrl,
494
+ checks: ["broken_links"],
495
+ force_fetch: false
496
+ })
497
+ }
498
+ );
499
+ const summaryOk = brokenLinksHealthCheckData?.result?.summary?.ok;
500
+ const checkOk = brokenLinksHealthCheckData?.result?.details?.broken_links?.ok;
501
+ const isError = brokenLinksHealthCheckData?.result?.details?.broken_links?.error;
502
+ if ((summaryOk === false || checkOk === false) && isError) {
503
+ ctx.body = {
504
+ brokenLinksHealthCheckData: buildBrokenLinksErrorResponse(brokenLinksHealthCheckData)
505
+ };
506
+ return;
507
+ }
508
+ ctx.body = {
509
+ brokenLinksHealthCheckData: buildBrokenLinksSuccessResponse(brokenLinksHealthCheckData)
510
+ };
511
+ },
512
+ async getMixedContentHealthCheck(ctx) {
513
+ const { monitorUrl } = ctx.request.body;
514
+ const mixedContentHealthCheckData = await service({ strapi }).makeBackendRequest(
515
+ `/healthcheck`,
516
+ {
517
+ method: "POST",
518
+ headers: {
519
+ "X-Requested-From": "craft"
520
+ },
521
+ body: JSON.stringify({
522
+ url: monitorUrl,
523
+ checks: ["mixed_content"],
524
+ force_fetch: false
525
+ })
526
+ }
527
+ );
528
+ ctx.body = { mixedContentHealthCheckData: buildSuccessResponse(mixedContentHealthCheckData) };
529
+ },
530
+ async getMonitorResponseTime(ctx) {
531
+ const monitorId = ctx.params.id;
532
+ const { start, end, region } = ctx.query;
533
+ const responseTimeData = await service({ strapi }).makeBackendRequest(
534
+ `/user/monitors/${monitorId}/response-time?start=${start}&end=${end}&region=${region || "default"}`,
535
+ {
536
+ method: "GET"
537
+ }
538
+ );
539
+ ctx.body = { responseTimeData };
540
+ },
541
+ async getMonitorIncidents(ctx) {
542
+ const monitorId = ctx.params.id;
543
+ const incidentsData = await service({ strapi }).makeBackendRequest(
544
+ `/user/monitors/incidents?monitorId=${monitorId}&page=1&page_size=20&time_range=7D`,
545
+ {
546
+ method: "GET"
547
+ }
548
+ );
549
+ ctx.body = { incidentsData };
550
+ },
551
+ async getMonitorSettings(ctx) {
552
+ const monitorId = ctx.params.id;
553
+ const monitorSettingsData = await service({ strapi }).makeBackendRequest(
554
+ `/user/monitors/settings?id=${monitorId}`,
555
+ {
556
+ method: "GET"
557
+ }
558
+ );
559
+ ctx.body = { monitorSettingsData };
560
+ },
561
+ async createMonitor(ctx) {
562
+ const { ...data } = ctx.request.body;
563
+ const monitorsData = await service({ strapi }).makeBackendRequest(`/user/monitors`, {
564
+ method: "POST",
565
+ body: JSON.stringify(data)
566
+ });
567
+ ctx.body = { monitorsData };
568
+ },
569
+ async updateMonitor(ctx) {
570
+ const monitorId = ctx.params.id;
571
+ const { ...data } = ctx.request.body;
572
+ const monitorsData = await service({ strapi }).makeBackendRequest(
573
+ `/user/monitors/${monitorId}`,
574
+ {
575
+ method: "PUT",
576
+ body: JSON.stringify(data)
577
+ }
578
+ );
579
+ ctx.body = { monitorsData };
580
+ },
581
+ async deleteMonitor(ctx) {
582
+ const monitorId = ctx.params.id;
583
+ const monitorsData = await service({ strapi }).makeBackendRequest(
584
+ `/user/monitors/${monitorId}`,
585
+ {
586
+ method: "DELETE"
587
+ }
588
+ );
589
+ ctx.body = { monitorsData };
590
+ },
591
+ async deleteMonitors(ctx) {
592
+ const { monitorIds } = ctx.request.body;
593
+ const monitorsData = await service({ strapi }).makeBackendRequest(`/user/monitors`, {
594
+ method: "PATCH",
595
+ body: JSON.stringify({ ids: monitorIds, action: "delete" })
596
+ });
597
+ ctx.body = { monitorsData };
598
+ }
599
+ });
600
+ const statusPage = ({ strapi }) => ({
601
+ async getStatusPages(ctx) {
602
+ const statusPagesData = await service({ strapi }).makeBackendRequest(`/user/status-pages`, {
603
+ method: "GET"
604
+ });
605
+ ctx.body = { statusPagesData };
606
+ },
607
+ async getStatusPagesByID(ctx) {
608
+ const id = ctx.params.id;
609
+ const statusPagesData = await service({ strapi }).makeBackendRequest(
610
+ `/user/status-pages/${id}`,
611
+ {
612
+ method: "GET"
613
+ }
614
+ );
615
+ ctx.body = { statusPagesData };
616
+ },
617
+ async saveStatusPages(ctx) {
618
+ const { name, monitor_ids, is_published } = ctx.request.body;
619
+ const statusPagesData = await service({ strapi }).makeBackendRequest(`/user/status-pages`, {
620
+ method: "POST",
621
+ body: JSON.stringify({ name, monitor_ids, is_published })
622
+ });
623
+ ctx.body = { statusPagesData };
624
+ },
625
+ async updateStatusPages(ctx) {
626
+ const { id, ...data } = ctx.request.body;
627
+ const statusPagesData = await service({ strapi }).makeBackendRequest(
628
+ `/user/status-pages/${id}`,
629
+ {
630
+ method: "PUT",
631
+ body: JSON.stringify(data)
632
+ }
633
+ );
634
+ ctx.body = { statusPagesData };
635
+ },
636
+ async resetLink(ctx) {
637
+ const { id } = ctx.request.body;
638
+ const statusPagesData = await service({ strapi }).makeBackendRequest(
639
+ `/user/status-pages/${id}/reset`,
640
+ {
641
+ method: "POST"
642
+ }
643
+ );
644
+ ctx.body = { statusPagesData };
645
+ },
646
+ async deleteStatusPages(ctx) {
647
+ const id = ctx.params.id;
648
+ const statusPagesData = await service({ strapi }).makeBackendRequest(
649
+ `/user/status-pages/${id}`,
650
+ {
651
+ method: "DELETE"
652
+ }
653
+ );
654
+ ctx.body = { statusPagesData };
655
+ }
656
+ });
657
+ const regions = ({ strapi }) => ({
658
+ async getRegions(ctx) {
659
+ const regionsData = await service({ strapi }).makeBackendRequest(`/regions`, {
660
+ method: "GET"
661
+ });
662
+ ctx.body = { regionsData };
663
+ }
664
+ });
665
+ const userDetails = ({ strapi }) => ({
666
+ async getUserDetails(ctx) {
667
+ const userDetailsData = await service({ strapi }).makeBackendRequest(`/user/details`, {
668
+ method: "GET"
669
+ });
670
+ ctx.body = { userDetailsData };
671
+ }
672
+ });
673
+ const notificationChannels = ({ strapi }) => ({
674
+ async getNotificationChannels(ctx) {
675
+ const notificationChannelsData = await service({ strapi }).makeBackendRequest(
676
+ `/user/integrations`,
677
+ {
678
+ method: "GET"
679
+ }
680
+ );
681
+ ctx.body = { notificationChannelsData };
682
+ },
683
+ async createNotificationChannel(ctx) {
684
+ const { ...data } = ctx.request.body;
685
+ const notificationChannelsData = await service({ strapi }).makeBackendRequest(
686
+ `/user/integrations`,
687
+ {
688
+ method: "POST",
689
+ body: JSON.stringify(data)
690
+ }
691
+ );
692
+ ctx.body = { notificationChannelsData };
693
+ },
694
+ async getSupportedIntegrations(ctx) {
695
+ const supportedIntegrationsData = await service({ strapi }).makeBackendRequest(
696
+ `/integrations/supported`,
697
+ {
698
+ method: "GET"
699
+ }
700
+ );
701
+ ctx.body = { supportedIntegrationsData };
702
+ },
703
+ async testNotificationChannel(ctx) {
704
+ const { id } = ctx.params;
705
+ const testResult = await service({ strapi }).makeBackendRequest(
706
+ `/user/integrations/${id}/test`,
707
+ {
708
+ method: "POST"
709
+ }
710
+ );
711
+ ctx.body = { testResult };
712
+ },
713
+ async updateNotificationChannel(ctx) {
714
+ const { id } = ctx.params;
715
+ const { ...data } = ctx.request.body;
716
+ const updatedChannel = await service({ strapi }).makeBackendRequest(
717
+ `/user/integrations/${id}`,
718
+ {
719
+ method: "PUT",
720
+ body: JSON.stringify(data)
721
+ }
722
+ );
723
+ ctx.body = { updatedChannel };
724
+ },
725
+ async deleteNotificationChannel(ctx) {
726
+ const { id } = ctx.params;
727
+ const deleteResult = await service({ strapi }).makeBackendRequest(`/user/integrations/${id}`, {
728
+ method: "DELETE"
729
+ });
730
+ ctx.body = { deleteResult };
731
+ }
732
+ });
733
+ const controllers = {
734
+ controller,
735
+ settings,
736
+ monitor,
737
+ statusPage,
738
+ regions,
739
+ userDetails,
740
+ notificationChannels
741
+ };
742
+ const middlewares = {};
743
+ const policies = {};
744
+ const routes = {
745
+ admin: {
746
+ type: "admin",
747
+ routes: [
748
+ {
749
+ method: "GET",
750
+ path: "/settings",
751
+ handler: "settings.get",
752
+ config: {
753
+ policies: [],
754
+ auth: false
755
+ }
756
+ },
757
+ {
758
+ method: "POST",
759
+ path: "/settings",
760
+ handler: "settings.set",
761
+ config: {
762
+ policies: [],
763
+ auth: false
764
+ }
765
+ },
766
+ {
767
+ method: "GET",
768
+ path: "/monitor/:id",
769
+ handler: "monitor.getById",
770
+ config: {
771
+ policies: [],
772
+ auth: false
773
+ }
774
+ },
775
+ {
776
+ method: "GET",
777
+ path: "/monitors",
778
+ handler: "monitor.get",
779
+ config: {
780
+ policies: [],
781
+ auth: false
782
+ }
783
+ },
784
+ {
785
+ method: "GET",
786
+ path: "/monitor/:id/uptime-stats",
787
+ handler: "monitor.getMonitorUptimeStats",
788
+ config: {
789
+ policies: [],
790
+ auth: false
791
+ }
792
+ },
793
+ {
794
+ method: "GET",
795
+ path: "/monitor/:id/histogram",
796
+ handler: "monitor.getMonitorHistogram",
797
+ config: {
798
+ policies: [],
799
+ auth: false
800
+ }
801
+ },
802
+ {
803
+ method: "POST",
804
+ path: "/monitor/health-check",
805
+ handler: "monitor.getHealthChecks",
806
+ config: {
807
+ policies: [],
808
+ auth: false
809
+ }
810
+ },
811
+ {
812
+ method: "POST",
813
+ path: "/monitor/health-check/uptime",
814
+ handler: "monitor.getUptimeHealthCheck",
815
+ config: {
816
+ policies: [],
817
+ auth: false
818
+ }
819
+ },
820
+ {
821
+ method: "POST",
822
+ path: "/monitor/health-check/ssl",
823
+ handler: "monitor.getSslHealthCheck",
824
+ config: {
825
+ policies: [],
826
+ auth: false
827
+ }
828
+ },
829
+ {
830
+ method: "POST",
831
+ path: "/monitor/health-check/domain",
832
+ handler: "monitor.getDomainHealthCheck",
833
+ config: {
834
+ policies: [],
835
+ auth: false
836
+ }
837
+ },
838
+ {
839
+ method: "POST",
840
+ path: "/monitor/health-check/lighthouse",
841
+ handler: "monitor.getLighthouseHealthCheck",
842
+ config: {
843
+ policies: [],
844
+ auth: false
845
+ }
846
+ },
847
+ {
848
+ method: "POST",
849
+ path: "/monitor/health-check/broken-links",
850
+ handler: "monitor.getBrokenLinksHealthCheck",
851
+ config: {
852
+ policies: [],
853
+ auth: false
854
+ }
855
+ },
856
+ {
857
+ method: "POST",
858
+ path: "/monitor/health-check/mixed-content",
859
+ handler: "monitor.getMixedContentHealthCheck",
860
+ config: {
861
+ policies: [],
862
+ auth: false
863
+ }
864
+ },
865
+ {
866
+ method: "GET",
867
+ path: "/monitor/:id/response-time",
868
+ handler: "monitor.getMonitorResponseTime",
869
+ config: {
870
+ policies: [],
871
+ auth: false
872
+ }
873
+ },
874
+ {
875
+ method: "GET",
876
+ path: "/monitor/:id/incidents",
877
+ handler: "monitor.getMonitorIncidents",
878
+ config: {
879
+ policies: [],
880
+ auth: false
881
+ }
882
+ },
883
+ {
884
+ method: "GET",
885
+ path: "/status-pages",
886
+ handler: "statusPage.getStatusPages",
887
+ config: {
888
+ policies: [],
889
+ auth: false
890
+ }
891
+ },
892
+ {
893
+ method: "GET",
894
+ path: "/status-pages/:id",
895
+ handler: "statusPage.getStatusPagesByID",
896
+ config: {
897
+ policies: [],
898
+ auth: false
899
+ }
900
+ },
901
+ {
902
+ method: "POST",
903
+ path: "/status-pages",
904
+ handler: "statusPage.saveStatusPages",
905
+ config: {
906
+ policies: [],
907
+ auth: false
908
+ }
909
+ },
910
+ {
911
+ method: "PUT",
912
+ path: "/status-pages",
913
+ handler: "statusPage.updateStatusPages",
914
+ config: {
915
+ policies: [],
916
+ auth: false
917
+ }
918
+ },
919
+ {
920
+ method: "POST",
921
+ path: "/status-pages/reset",
922
+ handler: "statusPage.resetLink",
923
+ config: {
924
+ policies: [],
925
+ auth: false
926
+ }
927
+ },
928
+ {
929
+ method: "DELETE",
930
+ path: "/status-pages/:id",
931
+ handler: "statusPage.deleteStatusPages",
932
+ config: {
933
+ policies: [],
934
+ auth: false
935
+ }
936
+ },
937
+ {
938
+ method: "GET",
939
+ path: "/regions",
940
+ handler: "regions.getRegions",
941
+ config: {
942
+ policies: [],
943
+ auth: false
944
+ }
945
+ },
946
+ {
947
+ method: "GET",
948
+ path: "/monitor/settings/:id",
949
+ handler: "monitor.getMonitorSettings",
950
+ config: {
951
+ policies: [],
952
+ auth: false
953
+ }
954
+ },
955
+ {
956
+ method: "GET",
957
+ path: "/user/details",
958
+ handler: "userDetails.getUserDetails",
959
+ config: {
960
+ policies: [],
961
+ auth: false
962
+ }
963
+ },
964
+ {
965
+ method: "GET",
966
+ path: "/notification-channels",
967
+ handler: "notificationChannels.getNotificationChannels",
968
+ config: {
969
+ policies: [],
970
+ auth: false
971
+ }
972
+ },
973
+ {
974
+ method: "POST",
975
+ path: "/notification-channels",
976
+ handler: "notificationChannels.createNotificationChannel",
977
+ config: {
978
+ policies: [],
979
+ auth: false
980
+ }
981
+ },
982
+ {
983
+ method: "POST",
984
+ path: "/monitors",
985
+ handler: "monitor.createMonitor",
986
+ config: {
987
+ policies: [],
988
+ auth: false
989
+ }
990
+ },
991
+ {
992
+ method: "PUT",
993
+ path: "/monitors/:id",
994
+ handler: "monitor.updateMonitor",
995
+ config: {
996
+ policies: [],
997
+ auth: false
998
+ }
999
+ },
1000
+ {
1001
+ method: "DELETE",
1002
+ path: "/monitors/:id",
1003
+ handler: "monitor.deleteMonitor",
1004
+ config: {
1005
+ policies: [],
1006
+ auth: false
1007
+ }
1008
+ },
1009
+ {
1010
+ method: "POST",
1011
+ path: "/monitors/bulk-delete",
1012
+ handler: "monitor.deleteMonitors",
1013
+ config: {
1014
+ policies: [],
1015
+ auth: false
1016
+ }
1017
+ },
1018
+ {
1019
+ method: "GET",
1020
+ path: "/settings/get-primary-monitor-id",
1021
+ handler: "settings.getPrimaryMonitorId",
1022
+ config: {
1023
+ policies: [],
1024
+ auth: false
1025
+ }
1026
+ },
1027
+ {
1028
+ method: "POST",
1029
+ path: "/settings/set-primary-monitor-id",
1030
+ handler: "settings.setPrimaryMonitorId",
1031
+ config: {
1032
+ policies: [],
1033
+ auth: false
1034
+ }
1035
+ },
1036
+ {
1037
+ method: "GET",
1038
+ path: "/integrations/supported",
1039
+ handler: "notificationChannels.getSupportedIntegrations",
1040
+ config: {
1041
+ policies: [],
1042
+ auth: false
1043
+ }
1044
+ },
1045
+ {
1046
+ method: "PUT",
1047
+ path: "/notification-channels/:id",
1048
+ handler: "notificationChannels.updateNotificationChannel",
1049
+ config: {
1050
+ policies: [],
1051
+ auth: false
1052
+ }
1053
+ },
1054
+ {
1055
+ method: "POST",
1056
+ path: "/notification-channels/:id/test",
1057
+ handler: "notificationChannels.testNotificationChannel",
1058
+ config: {
1059
+ policies: [],
1060
+ auth: false
1061
+ }
1062
+ },
1063
+ {
1064
+ method: "DELETE",
1065
+ path: "/notification-channels/:id",
1066
+ handler: "notificationChannels.deleteNotificationChannel",
1067
+ config: {
1068
+ policies: [],
1069
+ auth: false
1070
+ }
1071
+ }
1072
+ ]
1073
+ }
1074
+ };
1075
+ const services = {
1076
+ service
1077
+ };
1078
+ const index = {
1079
+ register,
1080
+ bootstrap,
1081
+ destroy,
1082
+ config,
1083
+ controllers,
1084
+ routes,
1085
+ services,
1086
+ contentTypes,
1087
+ policies,
1088
+ middlewares
1089
+ };
1090
+ exports.default = index;