@@ -39,28 +39,28 @@ export interface IWebhookObject {
39
39
}
40
40
41
41
export class Webhooks {
42
- private config : IConfig
43
- private db : IStorageProvider
42
+ private _config : IConfig
43
+ private _db : IStorageProvider
44
44
static MemoryStorageProvider = MemoryStorageProvider
45
45
static LocalDiskStorageProvider = LocalDiskStorageProvider
46
46
47
47
constructor ( _config ?: IConfig ) {
48
- this . config = _config || { }
49
- this . db = this . config . storageProvider || new MemoryStorageProvider ( )
48
+ this . _config = _config || { }
49
+ this . _db = this . _config . storageProvider || new MemoryStorageProvider ( )
50
50
}
51
51
52
52
async getAll ( ) {
53
- return this . db . getAll ( )
53
+ return this . _db . getAll ( )
54
54
}
55
55
56
56
async getById ( webhookId : string ) : Promise < IWebhookObject | null > {
57
- const webhook = await this . db . getById ( webhookId )
57
+ const webhook = await this . _db . getById ( webhookId )
58
58
if ( ! webhook ) return null
59
59
return webhook
60
60
}
61
61
62
62
async getByTag ( tag : string ) : Promise < IWebhookObject [ ] | null > {
63
- const webhooks = await this . db . getByTag ( tag )
63
+ const webhooks = await this . _db . getByTag ( tag )
64
64
if ( ! webhooks ) return null
65
65
return webhooks
66
66
}
@@ -69,7 +69,7 @@ export class Webhooks {
69
69
if ( typeof events === 'string' ) events = [ events ]
70
70
const webhooks : IWebhookObject [ ] = [ ]
71
71
for ( const event of events ) {
72
- const results = await this . db . getByEvent ( event )
72
+ const results = await this . _db . getByEvent ( event )
73
73
if ( ! results ) continue
74
74
for ( const result of results ) {
75
75
if ( ! webhooks . find ( e => e . id === result . id ) ) webhooks . push ( result )
@@ -95,17 +95,17 @@ export class Webhooks {
95
95
created : createdDate . toJSON ( ) ,
96
96
modified : createdDate . toJSON ( )
97
97
}
98
- await this . db . add ( objectToAdd )
99
- return this . db . getById ( id )
98
+ await this . _db . add ( objectToAdd )
99
+ return this . _db . getById ( id )
100
100
}
101
101
102
102
async remove ( webhookId : string ) : Promise < boolean > {
103
- await this . db . remove ( webhookId )
103
+ await this . _db . remove ( webhookId )
104
104
return true
105
105
}
106
106
107
107
async triggerByEvent ( eventType : string , data : any , tagFilter ?: string ) {
108
- let webhooks = await this . db . getByEvent ( eventType )
108
+ let webhooks = await this . _db . getByEvent ( eventType )
109
109
if ( ! webhooks ) return null
110
110
if ( tagFilter ) webhooks = webhooks . filter ( e => e . tags . includes ( tagFilter ) )
111
111
for ( const hook of webhooks ) {
@@ -145,9 +145,7 @@ export class Webhooks {
145
145
}
146
146
}
147
147
return got . post ( url , gotConfig )
148
- } catch ( e ) {
149
- console . error ( e )
150
- }
148
+ } catch { }
151
149
}
152
150
}
153
151
0 commit comments