🐛 Fix accents
This commit is contained in:
parent
e028dc50bf
commit
98b567961f
6 changed files with 1332 additions and 289 deletions
|
@ -1,3 +1,4 @@
|
|||
grafana
|
||||
docs
|
||||
node_modules
|
||||
tests
|
|
@ -1,18 +0,0 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
grafana:
|
||||
container_name: grafana
|
||||
image: grafana/grafana
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./grafana:/var/lib/grafana
|
||||
ports:
|
||||
- '3003:3000'
|
||||
|
||||
grafana-to-ntfy:
|
||||
container_name: grafana-to-ntfy
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
NTFY_TOPIC: grafana-custom-alert-topic
|
1583
package-lock.json
generated
1583
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -7,8 +7,7 @@
|
|||
"start": "node dist/index.js",
|
||||
"dev": "ts-node-dev src/index.ts",
|
||||
"build": "tsc",
|
||||
"format": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
||||
"docker-dev": "docker-compose -f docker-compose.dev.yml up --build"
|
||||
"format": "prettier --config .prettierrc 'src/**/*.ts' --write"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -26,14 +25,15 @@
|
|||
"homepage": "https://gitlab.com/Saibe1111/grafana-to-ntfy#readme",
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/superagent": "^4.1.18",
|
||||
"prettier": "^2.8.8",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.4.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"superagent": "^8.0.9",
|
||||
"tslib": "^2.6.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { MessageHeader } from '../interface/MessageHeader';
|
||||
import { Priority } from '../enum/priority';
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import superagent from 'superagent';
|
||||
|
||||
export class NtfyMessage {
|
||||
private header: MessageHeader;
|
||||
|
@ -26,10 +26,11 @@ export class NtfyMessage {
|
|||
this.server = (process.env['NTFY_SERVER'] as string) || 'https://ntfy.sh';
|
||||
}
|
||||
|
||||
public async publish(): Promise<AxiosResponse> {
|
||||
const response = await axios.post(this.server + '/' + this.topic, this.message, {
|
||||
headers: this.transformMessageHeaderToObj(this.header)
|
||||
});
|
||||
public async publish(): Promise<superagent.Response> {
|
||||
const response = await superagent
|
||||
.post(this.server + '/' + this.topic)
|
||||
.set(this.transformMessageHeaderToObj(this.header))
|
||||
.send(this.message);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ export class GrafanaService {
|
|||
const messageActions = getActions(req.body.alerts[0].silenceURL, req.body.alerts[0].dashboardURL);
|
||||
const message = new NtfyMessage(messageTitle, messageDescription, messagePriotity, messageTags, messageActions);
|
||||
const response = await message.publish();
|
||||
if (response.status != 200) {
|
||||
if (!response.ok) {
|
||||
if (response.status == 403) {
|
||||
throw new Error('Forbidden');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue