@upsnap/strapi 1.0.0 → 1.0.1

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