Skip to content

Commit ee2530a

Browse files
committed
seperate examples into examples folder and exports
1 parent 3e68bb5 commit ee2530a

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

examples/basic.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Webhooks, MemoryStorageProvider } from '../src/index'
2+
3+
;(async () => {
4+
try {
5+
let wh = new Webhooks()
6+
await wh.add({
7+
url: 'https://localhost/urmom',
8+
events: [
9+
'user.create',
10+
'user.update',
11+
'ur.mom'
12+
]
13+
})
14+
const all = await wh.getAll()
15+
console.log('All >>> ', all)
16+
const byEvent = await wh.getByEvents('ur.mom')
17+
console.log('By Event >>> ', byEvent)
18+
} catch (e) {
19+
console.log(e)
20+
}
21+
})()

src/index.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface IWebhookObject {
2828
modified: string
2929
}
3030

31-
class Webhooks {
31+
export class Webhooks {
3232
private config: IConfig
3333
private db: IStorageProvider
3434

@@ -89,7 +89,7 @@ class Webhooks {
8989
}
9090
}
9191

92-
class MemoryStorageProvider {
92+
export class MemoryStorageProvider {
9393
db: IWebhookObject[]
9494

9595
constructor () {
@@ -125,16 +125,7 @@ class MemoryStorageProvider {
125125
}
126126
}
127127

128-
;(async () => {
129-
try {
130-
let wh = new Webhooks()
131-
await wh.add({
132-
url: 'https://localhost/urmom',
133-
events: ['sup']
134-
})
135-
const all = await wh.getAll()
136-
console.log(all)
137-
} catch (e) {
138-
console.log(e)
139-
}
140-
})()
128+
export default {
129+
Webhooks,
130+
MemoryStorageProvider
131+
}

0 commit comments

Comments
 (0)