Commit dfd223bc authored by nanahira's avatar nanahira

bump and for templating meta

parent 663c5bdc
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"koishi-target-def": "^1.0.0", "koishi-target-def": "^1.0.0",
"koishi-thirdeye": "^10.1.0", "koishi-thirdeye": "^10.1.4",
"lodash": "^4.17.21" "lodash": "^4.17.21"
}, },
"devDependencies": { "devDependencies": {
...@@ -5243,18 +5243,19 @@ ...@@ -5243,18 +5243,19 @@
} }
}, },
"node_modules/koishi-decorators": { "node_modules/koishi-decorators": {
"version": "2.0.1", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/koishi-decorators/-/koishi-decorators-2.0.1.tgz", "resolved": "https://registry.npmjs.org/koishi-decorators/-/koishi-decorators-2.0.3.tgz",
"integrity": "sha512-dDrBS4Su1NtmrkIeCdcCKsC6uaBYTRTspDdeeoPLOMuSJf6fqqXwxa2qEosvG5475MXs9SaNQDaKjh0gq/NY6A==", "integrity": "sha512-rAC3bJVdeIQmydUbOWy+SWqtczUJfUHSIQggR5+bVI9oKMxNuTfbik3xD/FnCMF84Z9aCklOz5MJOLPbaUs1pw==",
"dependencies": { "dependencies": {
"@types/koa": "^2.13.4", "@types/koa": "^2.13.4",
"@types/koa__router": "^8.0.11", "@types/koa__router": "^8.0.11",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mustache": "^4.2.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"typed-reflector": "^1.0.10" "typed-reflector": "^1.0.10"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.6.0" "koishi": "^4.7.0"
} }
}, },
"node_modules/koishi-target-def": { "node_modules/koishi-target-def": {
...@@ -5270,13 +5271,13 @@ ...@@ -5270,13 +5271,13 @@
} }
}, },
"node_modules/koishi-thirdeye": { "node_modules/koishi-thirdeye": {
"version": "10.1.0", "version": "10.1.4",
"resolved": "https://registry.npmjs.org/koishi-thirdeye/-/koishi-thirdeye-10.1.0.tgz", "resolved": "https://registry.npmjs.org/koishi-thirdeye/-/koishi-thirdeye-10.1.4.tgz",
"integrity": "sha512-ElobuJABbWmWdFkzaU6pUmHUCqvpAwIe43BwxwV2AOHWrFM7IJtS9W+rODfx4WaUrnP7KMy2+jPt5C4UyD8tYQ==", "integrity": "sha512-uOCBw/SsAqW3HtKU/iozJTogJXnvDbP98n/20+CaLoAe+xK05z6QToRR6hEk0CLsAYgSivkXbUsEKTBHKT4i/g==",
"dependencies": { "dependencies": {
"@types/koa": "^2.13.4", "@types/koa": "^2.13.4",
"@types/koa__router": "^8.0.11", "@types/koa__router": "^8.0.11",
"koishi-decorators": "^2.0.1", "koishi-decorators": "^2.0.3",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"minato-decorators": "^2.0.6", "minato-decorators": "^2.0.6",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
...@@ -5540,6 +5541,14 @@ ...@@ -5540,6 +5541,14 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}, },
"node_modules/mustache": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz",
"integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==",
"bin": {
"mustache": "bin/mustache"
}
},
"node_modules/natural-compare": { "node_modules/natural-compare": {
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
...@@ -11779,13 +11788,14 @@ ...@@ -11779,13 +11788,14 @@
} }
}, },
"koishi-decorators": { "koishi-decorators": {
"version": "2.0.1", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/koishi-decorators/-/koishi-decorators-2.0.1.tgz", "resolved": "https://registry.npmjs.org/koishi-decorators/-/koishi-decorators-2.0.3.tgz",
"integrity": "sha512-dDrBS4Su1NtmrkIeCdcCKsC6uaBYTRTspDdeeoPLOMuSJf6fqqXwxa2qEosvG5475MXs9SaNQDaKjh0gq/NY6A==", "integrity": "sha512-rAC3bJVdeIQmydUbOWy+SWqtczUJfUHSIQggR5+bVI9oKMxNuTfbik3xD/FnCMF84Z9aCklOz5MJOLPbaUs1pw==",
"requires": { "requires": {
"@types/koa": "^2.13.4", "@types/koa": "^2.13.4",
"@types/koa__router": "^8.0.11", "@types/koa__router": "^8.0.11",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mustache": "^4.2.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"typed-reflector": "^1.0.10" "typed-reflector": "^1.0.10"
} }
...@@ -11799,13 +11809,13 @@ ...@@ -11799,13 +11809,13 @@
} }
}, },
"koishi-thirdeye": { "koishi-thirdeye": {
"version": "10.1.0", "version": "10.1.4",
"resolved": "https://registry.npmjs.org/koishi-thirdeye/-/koishi-thirdeye-10.1.0.tgz", "resolved": "https://registry.npmjs.org/koishi-thirdeye/-/koishi-thirdeye-10.1.4.tgz",
"integrity": "sha512-ElobuJABbWmWdFkzaU6pUmHUCqvpAwIe43BwxwV2AOHWrFM7IJtS9W+rODfx4WaUrnP7KMy2+jPt5C4UyD8tYQ==", "integrity": "sha512-uOCBw/SsAqW3HtKU/iozJTogJXnvDbP98n/20+CaLoAe+xK05z6QToRR6hEk0CLsAYgSivkXbUsEKTBHKT4i/g==",
"requires": { "requires": {
"@types/koa": "^2.13.4", "@types/koa": "^2.13.4",
"@types/koa__router": "^8.0.11", "@types/koa__router": "^8.0.11",
"koishi-decorators": "^2.0.1", "koishi-decorators": "^2.0.3",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"minato-decorators": "^2.0.6", "minato-decorators": "^2.0.6",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
...@@ -12016,6 +12026,11 @@ ...@@ -12016,6 +12026,11 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}, },
"mustache": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz",
"integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ=="
},
"natural-compare": { "natural-compare": {
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
}, },
"dependencies": { "dependencies": {
"koishi-target-def": "^1.0.0", "koishi-target-def": "^1.0.0",
"koishi-thirdeye": "^10.1.0", "koishi-thirdeye": "^10.1.4",
"lodash": "^4.17.21" "lodash": "^4.17.21"
}, },
"peerDependencies": { "peerDependencies": {
......
...@@ -7,6 +7,8 @@ import { ...@@ -7,6 +7,8 @@ import {
LifecycleEvents, LifecycleEvents,
InjectLogger, InjectLogger,
MultiInstancePlugin, MultiInstancePlugin,
Post,
KoaContext,
} from 'koishi-thirdeye'; } from 'koishi-thirdeye';
import { Adapter, Logger, Router } from 'koishi'; import { Adapter, Logger, Router } from 'koishi';
import _ from 'lodash'; import _ from 'lodash';
...@@ -55,24 +57,22 @@ export default class AlertmanagerPlugin ...@@ -55,24 +57,22 @@ export default class AlertmanagerPlugin
return this.instances.find((instance) => instance.isMatch(token)); return this.instances.find((instance) => instance.isMatch(token));
} }
onApply() { @Post('{{path}}')
super.onApply(); async onAlert(ctx: KoaContext) {
this.router.post(this.config.path, async (ctx) => { const instance = this.getInstance(ctx.headers['authorization']);
const instance = this.getInstance(ctx.headers['authorization']); if (!instance) {
if (!instance) {
ctx.body = {
status: 'error',
error: 'unauthorized',
};
ctx.status = 403;
return;
}
this.logger.warn(JSON.stringify(ctx.request.body));
await instance.trigger(ctx.request.body);
ctx.body = { ctx.body = {
status: 'success', status: 'error',
error: 'unauthorized',
}; };
ctx.status = 200; ctx.status = 403;
}); return;
}
this.logger.warn(JSON.stringify(ctx.request.body));
await instance.trigger(ctx.request.body);
ctx.body = {
status: 'success',
};
ctx.status = 200;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment