Merge pull request #2382 from bluewave-labs/feat/format-check
Feat/format check
This commit is contained in:
6 files changed
+98
-30
No files matched your search
@@ -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,
|
||||
placeholder: PropTypes.string,
|
||||
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(
|
||||
PropTypes.shape({
|
||||
_id: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])
|
||||
|
||||
+2
@@ -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.
|
||||
- [ ] I have included the issue # in the PR.
|
||||
- [ ] I have added i18n support to visible strings (instead of `<div>Add</div>`, use):
|
||||
|
||||
```Javascript
|
||||
const { t } = useTranslation();
|
||||
<div>{t('add')}</div>
|
||||
```
|
||||
|
||||
- [ ] 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).
|
||||
- [ ] My PR is granular and targeted to one specific feature.
|
||||
@@ -4,14 +4,14 @@ import { handleError, handleValidationError } from "./controllerUtils.js";
|
||||
const SERVICE_NAME = "NotificationController";
|
||||
|
||||
const NOTIFICATION_TYPES = {
|
||||
WEBHOOK: 'webhook',
|
||||
TELEGRAM: 'telegram'
|
||||
WEBHOOK: "webhook",
|
||||
TELEGRAM: "telegram",
|
||||
};
|
||||
|
||||
const PLATFORMS = {
|
||||
SLACK: 'slack',
|
||||
DISCORD: 'discord',
|
||||
TELEGRAM: 'telegram'
|
||||
SLACK: "slack",
|
||||
DISCORD: "discord",
|
||||
TELEGRAM: "telegram",
|
||||
};
|
||||
|
||||
class NotificationController {
|
||||
@@ -40,7 +40,7 @@ class NotificationController {
|
||||
// Create a simplified networkResponse similar to what would come from monitoring
|
||||
const networkResponse = {
|
||||
monitorId,
|
||||
status
|
||||
status,
|
||||
};
|
||||
|
||||
// Use the statusService to get monitor details and handle status change logic
|
||||
@@ -73,7 +73,7 @@ class NotificationController {
|
||||
monitor: {
|
||||
_id: "test-monitor-id",
|
||||
name: "Test Monitor",
|
||||
url: "https://example.com"
|
||||
url: "https://example.com",
|
||||
},
|
||||
status: true,
|
||||
statusChanged: true,
|
||||
@@ -87,8 +87,8 @@ class NotificationController {
|
||||
isValid: false,
|
||||
error: {
|
||||
msg: this.stringService.telegramRequiresBotTokenAndChatId,
|
||||
status: 400
|
||||
}
|
||||
status: 400,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ class NotificationController {
|
||||
notification: {
|
||||
type: NOTIFICATION_TYPES.WEBHOOK,
|
||||
platform: PLATFORMS.TELEGRAM,
|
||||
config: { botToken, chatId }
|
||||
}
|
||||
config: { botToken, chatId },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ class NotificationController {
|
||||
isValid: false,
|
||||
error: {
|
||||
msg: this.stringService.webhookUrlRequired,
|
||||
status: 400
|
||||
}
|
||||
status: 400,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ class NotificationController {
|
||||
notification: {
|
||||
type: NOTIFICATION_TYPES.WEBHOOK,
|
||||
platform: platform,
|
||||
config: { webhookUrl }
|
||||
}
|
||||
config: { webhookUrl },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class NotificationController {
|
||||
if (platform === null) {
|
||||
return res.error({
|
||||
msg: this.stringService.platformRequired,
|
||||
status: 400
|
||||
status: 400,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ class NotificationController {
|
||||
const platformHandlers = {
|
||||
[PLATFORMS.TELEGRAM]: () => this.handleTelegramTest(botToken, chatId),
|
||||
// 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;
|
||||
@@ -162,7 +162,7 @@ class NotificationController {
|
||||
} else {
|
||||
return res.error({
|
||||
msg: this.stringService.testNotificationFailed,
|
||||
status: 400
|
||||
status: 400,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -11,15 +11,9 @@ class NotificationRoutes {
|
||||
initializeRoutes() {
|
||||
this.router.use(verifyJWT);
|
||||
|
||||
this.router.post(
|
||||
"/trigger",
|
||||
this.notificationController.triggerNotification
|
||||
);
|
||||
this.router.post("/trigger", this.notificationController.triggerNotification);
|
||||
|
||||
this.router.post(
|
||||
"/test-webhook",
|
||||
this.notificationController.testWebhook
|
||||
);
|
||||
this.router.post("/test-webhook", this.notificationController.testWebhook);
|
||||
}
|
||||
|
||||
getRouter() {
|
||||
|
||||
@@ -2,13 +2,22 @@
|
||||
<mj-body>
|
||||
<mj-section>
|
||||
<mj-column>
|
||||
<mj-text font-size="20px" font-family="Helvetica Neue">
|
||||
<mj-text
|
||||
font-size="20px"
|
||||
font-family="Helvetica Neue"
|
||||
>
|
||||
Hello!
|
||||
</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.
|
||||
</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.
|
||||
</mj-text>
|
||||
</mj-column>
|
||||
|
||||
Reference in new issue
Block a user