Merge pull request #2382 from bluewave-labs/feat/format-check

Feat/format check
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-06-01 11:57:08 -07:00
commit 41e3e262fb
7 files changed
+99 -31

No files matched your search

+62
View File
@@ -0,0 +1,62 @@
name: Format Check (Client & Server)
on:
pull_request:
workflow_dispatch:
jobs:
format-client:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install client dependencies
working-directory: client
run: npm ci
- name: Check client formatting
working-directory: client
run: npm run format-check
format-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install server dependencies
working-directory: server
run: npm ci
- name: Check server formatting
working-directory: server
run: npm run format-check
close-pr-if-needed:
if: always()
runs-on: ubuntu-latest
needs: [format-client, format-server]
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Get PR number
id: pr
run: echo "PR_NUMBER=$(jq -r .pull_request.number "$GITHUB_EVENT_PATH")" >> $GITHUB_ENV
- name: Close PR using GitHub CLI
if: |
needs.format-client.result == 'failure' ||
needs.format-server.result == 'failure'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr close "$PR_NUMBER" --delete-branch --comment "❌ Formatting check failed — PR auto-closed.
Please run \`npm run format\` and push again."
@@ -161,7 +161,8 @@ Select.propTypes = {
label: PropTypes.string, label: PropTypes.string,
placeholder: PropTypes.string, placeholder: PropTypes.string,
isHidden: PropTypes.bool, isHidden: PropTypes.bool,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]).isRequired, value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])
.isRequired,
items: PropTypes.arrayOf( items: PropTypes.arrayOf(
PropTypes.shape({ PropTypes.shape({
_id: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]) _id: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])
+2
View File
@@ -14,10 +14,12 @@ Fixes #123
- [ ] (Do not skip this or your PR will be closed) I have performed a self-review and testing of my code. - [ ] (Do not skip this or your PR will be closed) I have performed a self-review and testing of my code.
- [ ] I have included the issue # in the PR. - [ ] I have included the issue # in the PR.
- [ ] I have added i18n support to visible strings (instead of `<div>Add</div>`, use): - [ ] I have added i18n support to visible strings (instead of `<div>Add</div>`, use):
```Javascript ```Javascript
const { t } = useTranslation(); const { t } = useTranslation();
<div>{t('add')}</div> <div>{t('add')}</div>
``` ```
- [ ] The issue I am working on is assigned to me. - [ ] The issue I am working on is assigned to me.
- [ ] I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application). - [ ] I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
- [ ] My PR is granular and targeted to one specific feature. - [ ] My PR is granular and targeted to one specific feature.
+18 -18
View File
@@ -4,14 +4,14 @@ import { handleError, handleValidationError } from "./controllerUtils.js";
const SERVICE_NAME = "NotificationController"; const SERVICE_NAME = "NotificationController";
const NOTIFICATION_TYPES = { const NOTIFICATION_TYPES = {
WEBHOOK: 'webhook', WEBHOOK: "webhook",
TELEGRAM: 'telegram' TELEGRAM: "telegram",
}; };
const PLATFORMS = { const PLATFORMS = {
SLACK: 'slack', SLACK: "slack",
DISCORD: 'discord', DISCORD: "discord",
TELEGRAM: 'telegram' TELEGRAM: "telegram",
}; };
class NotificationController { class NotificationController {
@@ -40,7 +40,7 @@ class NotificationController {
// Create a simplified networkResponse similar to what would come from monitoring // Create a simplified networkResponse similar to what would come from monitoring
const networkResponse = { const networkResponse = {
monitorId, monitorId,
status status,
}; };
// Use the statusService to get monitor details and handle status change logic // Use the statusService to get monitor details and handle status change logic
@@ -73,7 +73,7 @@ class NotificationController {
monitor: { monitor: {
_id: "test-monitor-id", _id: "test-monitor-id",
name: "Test Monitor", name: "Test Monitor",
url: "https://example.com" url: "https://example.com",
}, },
status: true, status: true,
statusChanged: true, statusChanged: true,
@@ -87,8 +87,8 @@ class NotificationController {
isValid: false, isValid: false,
error: { error: {
msg: this.stringService.telegramRequiresBotTokenAndChatId, msg: this.stringService.telegramRequiresBotTokenAndChatId,
status: 400 status: 400,
} },
}; };
} }
@@ -97,8 +97,8 @@ class NotificationController {
notification: { notification: {
type: NOTIFICATION_TYPES.WEBHOOK, type: NOTIFICATION_TYPES.WEBHOOK,
platform: PLATFORMS.TELEGRAM, platform: PLATFORMS.TELEGRAM,
config: { botToken, chatId } config: { botToken, chatId },
} },
}; };
} }
@@ -108,8 +108,8 @@ class NotificationController {
isValid: false, isValid: false,
error: { error: {
msg: this.stringService.webhookUrlRequired, msg: this.stringService.webhookUrlRequired,
status: 400 status: 400,
} },
}; };
} }
@@ -118,8 +118,8 @@ class NotificationController {
notification: { notification: {
type: NOTIFICATION_TYPES.WEBHOOK, type: NOTIFICATION_TYPES.WEBHOOK,
platform: platform, platform: platform,
config: { webhookUrl } config: { webhookUrl },
} },
}; };
} }
@@ -130,7 +130,7 @@ class NotificationController {
if (platform === null) { if (platform === null) {
return res.error({ return res.error({
msg: this.stringService.platformRequired, msg: this.stringService.platformRequired,
status: 400 status: 400,
}); });
} }
@@ -138,7 +138,7 @@ class NotificationController {
const platformHandlers = { const platformHandlers = {
[PLATFORMS.TELEGRAM]: () => this.handleTelegramTest(botToken, chatId), [PLATFORMS.TELEGRAM]: () => this.handleTelegramTest(botToken, chatId),
// Default handler for webhook-based platforms (Slack, Discord, etc.) // Default handler for webhook-based platforms (Slack, Discord, etc.)
default: () => this.handleWebhookTest(webhookUrl, platform) default: () => this.handleWebhookTest(webhookUrl, platform),
}; };
const handler = platformHandlers[platform] || platformHandlers.default; const handler = platformHandlers[platform] || platformHandlers.default;
@@ -162,7 +162,7 @@ class NotificationController {
} else { } else {
return res.error({ return res.error({
msg: this.stringService.testNotificationFailed, msg: this.stringService.testNotificationFailed,
status: 400 status: 400,
}); });
} }
} catch (error) { } catch (error) {
+1 -1
View File
@@ -38,7 +38,7 @@ const updateStatusPage = async (statusPageData, image) => {
data: image.buffer, data: image.buffer,
contentType: image.mimetype, contentType: image.mimetype,
}; };
}else{ } else {
statusPageData.logo = null; statusPageData.logo = null;
} }
+2 -8
View File
@@ -11,15 +11,9 @@ class NotificationRoutes {
initializeRoutes() { initializeRoutes() {
this.router.use(verifyJWT); this.router.use(verifyJWT);
this.router.post( this.router.post("/trigger", this.notificationController.triggerNotification);
"/trigger",
this.notificationController.triggerNotification
);
this.router.post( this.router.post("/test-webhook", this.notificationController.testWebhook);
"/test-webhook",
this.notificationController.testWebhook
);
} }
getRouter() { getRouter() {
+12 -3
View File
@@ -2,13 +2,22 @@
<mj-body> <mj-body>
<mj-section> <mj-section>
<mj-column> <mj-column>
<mj-text font-size="20px" font-family="Helvetica Neue"> <mj-text
font-size="20px"
font-family="Helvetica Neue"
>
Hello! Hello!
</mj-text> </mj-text>
<mj-text font-size="16px" font-family="Helvetica Neue"> <mj-text
font-size="16px"
font-family="Helvetica Neue"
>
This is a test email from the Monitoring System. This is a test email from the Monitoring System.
</mj-text> </mj-text>
<mj-text font-size="14px" font-family="Helvetica Neue"> <mj-text
font-size="14px"
font-family="Helvetica Neue"
>
If you're receiving this, your email configuration is working correctly. If you're receiving this, your email configuration is working correctly.
</mj-text> </mj-text>
</mj-column> </mj-column>