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