@@ -24,7 +24,7 @@ export class PubsubService {
24
24
25
25
constructor ( ) {
26
26
const prevHost = localStorage . getItem ( "host" )
27
- if ( prevHost ) {
27
+ if ( prevHost ) {
28
28
console . log ( 'loaded previous host' , prevHost )
29
29
this . _currentHost$ . next ( prevHost )
30
30
}
@@ -38,7 +38,7 @@ export class PubsubService {
38
38
)
39
39
}
40
40
41
- setHost ( hostUrl : string ) {
41
+ setHost ( hostUrl : string ) {
42
42
this . _currentHost$ . next ( hostUrl )
43
43
44
44
localStorage . setItem ( "host" , hostUrl )
@@ -58,7 +58,7 @@ export class PubsubService {
58
58
localStorage . setItem ( "projects" , jsonList )
59
59
}
60
60
61
- createTopic ( projectId : string , topicId : string ) {
61
+ createTopic ( projectId : string , topicId : string ) {
62
62
const url = `${ this . _currentHost$ . value } /v1/projects/${ projectId } /topics/${ topicId } `
63
63
64
64
return this . http . put < Topic > ( url , { } )
@@ -68,13 +68,13 @@ export class PubsubService {
68
68
return this . http . get < { topics : Topic [ ] } > ( `${ this . _currentHost$ . value } /v1/projects/${ projectId } /topics` ) . pipe ( map ( incoming => incoming ?. topics || [ ] ) )
69
69
}
70
70
71
- createSubscription ( projectId : string , request : NewSubscriptionRequest ) {
71
+ createSubscription ( projectId : string , request : NewSubscriptionRequest ) {
72
72
const url = `${ this . _currentHost$ . value } /v1/projects/${ projectId } /subscriptions/${ request . name } `
73
73
74
- return this . http . put < Subscription > ( url , { topic : request . topic , pushConfig : request . pushConfig } )
74
+ return this . http . put < Subscription > ( url , { topic : request . topic , pushConfig : request . pushConfig } )
75
75
}
76
76
77
- deleteSubscription ( subscriptionPath : string ) {
77
+ deleteSubscription ( subscriptionPath : string ) {
78
78
const url = `${ this . _currentHost$ . value } /v1/${ subscriptionPath } `
79
79
return this . http . delete ( url )
80
80
}
@@ -83,8 +83,8 @@ export class PubsubService {
83
83
return this . http . get < { subscriptions ?: string [ ] } > ( `${ this . _currentHost$ . value } /v1/projects/${ projectId } /subscriptions` )
84
84
. pipe (
85
85
map ( incoming => incoming . subscriptions ) , // first we pull out the subscriptions object
86
- map ( subNames => subNames ?? [ ] ) ,
87
- map ( subNames => subNames . map ( name => ( { name, topic : 'undefined' } as Subscription ) ) ) // now we convert each string to a Subscription object (idk why, I think just wanted to learn rxjs mapping...)
86
+ map ( subNames => subNames ?? [ ] ) ,
87
+ map ( subNames => subNames . map ( name => ( { name, topic : 'undefined' } as Subscription ) ) ) // now we convert each string to a Subscription object (idk why, I think just wanted to learn rxjs mapping...)
88
88
)
89
89
}
90
90
@@ -95,12 +95,12 @@ export class PubsubService {
95
95
return this . http . get < { subscriptions ?: string [ ] } > ( url )
96
96
. pipe (
97
97
map ( incoming => incoming . subscriptions ) ,
98
- map ( subNames => subNames ?? [ ] ) ,
98
+ map ( subNames => subNames ?? [ ] ) ,
99
99
map ( subNames => subNames . map ( name => ( { name, topic : 'undefined' } as Subscription ) ) ) // now we convert each string to a Subscription object (idk why, I think just wanted to learn rxjs mapping...)
100
100
)
101
101
}
102
102
103
- getSubscriptionDetails ( subscriptionPath : string ) {
103
+ getSubscriptionDetails ( subscriptionPath : string ) {
104
104
const url = `${ this . _currentHost$ . value } /v1/${ subscriptionPath } `
105
105
return this . http . get < Subscription > ( url )
106
106
}
@@ -113,14 +113,14 @@ export class PubsubService {
113
113
) . pipe ( map ( incoming => incoming . receivedMessages ?? [ ] ) )
114
114
}
115
115
116
- ackMessage ( subscriptionPath :string , ackIds : string [ ] ) {
116
+ ackMessage ( subscriptionPath : string , ackIds : string [ ] ) {
117
117
const url = `${ this . _currentHost$ . value } /v1/${ subscriptionPath } :acknowledge`
118
- return this . http . post ( url , { ackIds} )
118
+ return this . http . post ( url , { ackIds } )
119
119
}
120
120
121
- publishMessages ( topicPath : string , messages : PubsubMessage [ ] ) {
121
+ publishMessages ( topicPath : string , messages : PubsubMessage [ ] ) {
122
122
const url = `${ this . _currentHost$ . value } /v1/${ topicPath } :publish`
123
- return this . http . post < { messageIds : string [ ] } > ( url , { messages} )
123
+ return this . http . post < { messageIds : string [ ] } > ( url , { messages } )
124
124
}
125
125
}
126
126
@@ -141,14 +141,14 @@ export interface ReceivedMessage {
141
141
}
142
142
143
143
export interface PubsubMessage {
144
- data : string
144
+ data : string
145
145
attributes ?: { [ key : string ] : string }
146
146
messageId ?: string
147
147
publishTime ?: string
148
148
orderingKey ?: string
149
149
}
150
150
151
- export interface PushConfig {
151
+ export interface PushConfig {
152
152
pushEndpoint : string
153
- attributes ?: { [ key : string ] : string }
153
+ attributes ?: { [ key : string ] : string }
154
154
}
0 commit comments