Allow to change ping, status and message via event
This commit is contained in:
parent
d9a928f7c8
commit
47e1d5d9e0
|
@ -1,6 +1,6 @@
|
|||
# UptimeKuma-api
|
||||
|
||||
Supports UptimeKuma versions from 1.13.1 to 1.18.0
|
||||
Supports UptimeKuma versions from 1.13.1 to 1.21.0
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "uptimekuma-api",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"types": "src/index.d.ts",
|
||||
|
|
6
src/index.d.ts
vendored
6
src/index.d.ts
vendored
|
@ -1,12 +1,18 @@
|
|||
export default class UptimeKumaApi {
|
||||
constructor(baseURL: string);
|
||||
|
||||
/**
|
||||
* Starts pushing heartbeats to the server
|
||||
* @param code The monitor code
|
||||
* @param interval The interval in seconds
|
||||
*/
|
||||
startPushing(code: string, interval?: number);
|
||||
|
||||
cancelPushing();
|
||||
|
||||
on(event: "pushSuccessful", handle: (url: string) => void);
|
||||
on(event: "pushFailed", handle: (url: string, err: Error) => void);
|
||||
on(event: "prePush", handle: (url: string, params: {status:"up"|"down",msg:string,ping?:number}) => void);
|
||||
|
||||
status(name?:string): Promise<[{
|
||||
id: number,
|
||||
|
|
|
@ -12,7 +12,9 @@ module.exports = class UptimeKumaApi extends EventEmitter {
|
|||
}
|
||||
|
||||
push(url) {
|
||||
client.get(url).then(res => {
|
||||
let params = {status:"up",msg:"OK",ping:undefined};
|
||||
this.emit("prePush", url, params);
|
||||
client.get(url,{params}).then(res => {
|
||||
this.emit("pushSuccessful", url);
|
||||
}).catch(err => {
|
||||
this.emit("pushFailed", url, err);
|
||||
|
|
Loading…
Reference in a new issue