@nu-art/push-pub-sub-backend 0.400.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ export declare const ModulePackBE_PushPubSub: (import("../modules/ModuleBE_PushSessionDB.js").ModuleBE_PushSessionDB_Class | import("../modules/ModuleBE_PushSubscriptionDB.js").ModuleBE_PushSubscriptionDB_Class | import("@nu-art/thunderstorm-backend").ModuleBE_BaseApi_Class<import("@nu-art/push-pub-sub-shared/push-subscription/types").DBProto_PushSubscription> | import("../modules/ModuleBE_PushMessagesHistoryDB.js").ModuleBE_PushMessagesHistoryDB_Class | import("../modules/ModuleBE_PushPubSub.js").ModuleBE_PushPubSub_Class)[];
2
+ export * from '../modules/ModuleBE_PushPubSub.js';
3
+ export * from '../modules/PushKey.js';
@@ -0,0 +1,30 @@
1
+ /*
2
+ * A generic push pub sub infra for webapps
3
+ *
4
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { ModuleBE_PushPubSub } from '../modules/ModuleBE_PushPubSub.js';
19
+ import { ModuleBE_PushSubscriptionAPI, ModuleBE_PushSubscriptionDB } from '../modules/ModuleBE_PushSubscriptionDB.js';
20
+ import { ModuleBE_PushSessionDB } from '../modules/ModuleBE_PushSessionDB.js';
21
+ import { ModuleBE_PushMessagesHistoryDB } from '../modules/ModuleBE_PushMessagesHistoryDB.js';
22
+ export const ModulePackBE_PushPubSub = [
23
+ ModuleBE_PushPubSub,
24
+ ModuleBE_PushSubscriptionDB,
25
+ ModuleBE_PushSubscriptionAPI,
26
+ ModuleBE_PushMessagesHistoryDB,
27
+ ModuleBE_PushSessionDB,
28
+ ];
29
+ export * from '../modules/ModuleBE_PushPubSub.js';
30
+ export * from '../modules/PushKey.js';
@@ -0,0 +1,5 @@
1
+ import { DefaultDef_Group } from '@nu-art/permissions-shared';
2
+ import { DefaultDef_Domain, DefaultDef_Package } from '@nu-art/permissions-backend/types';
3
+ export declare const PermissionsDomain_PushMessages: Readonly<DefaultDef_Domain>;
4
+ export declare const PermissionsGroup_PushMessanger: Readonly<DefaultDef_Group>;
5
+ export declare const PermissionsPackage_PushMessages: DefaultDef_Package;
@@ -0,0 +1,45 @@
1
+ import { CreateDefaultAccessLevels, DefaultAccessLevel_Admin } from '@nu-art/permissions-shared';
2
+ import { ApiDef_PushMessages } from '@nu-art/push-pub-sub-shared';
3
+ import { Domain_Developer } from '@nu-art/permissions-backend/permissions';
4
+ import { ModuleBE_PushSubscriptionAPI } from '../modules/ModuleBE_PushSubscriptionDB.js';
5
+ import { _values } from '@nu-art/ts-common';
6
+ const Domain_PushMessages_ID = 'ce2e840bb639c34887ae19c2c7c82c11';
7
+ const DefaultAccessLevel_Passive = Object.freeze({ name: 'Passive', value: 0 });
8
+ const DefaultAccessLevel_Active = Object.freeze({ name: 'Active', value: 0 });
9
+ const DefaultAccessLevel_Tester = Object.freeze({ name: 'Tester', value: 600 });
10
+ const accessLevels = [{ ...DefaultAccessLevel_Passive }, { ...DefaultAccessLevel_Active }, { ...DefaultAccessLevel_Tester }];
11
+ const _PermissionsDomain_PushMessages = {
12
+ _id: Domain_PushMessages_ID,
13
+ namespace: 'Push Messages',
14
+ dbNames: [],
15
+ levels: CreateDefaultAccessLevels(Domain_PushMessages_ID, accessLevels),
16
+ customApis: [
17
+ ..._values(ModuleBE_PushSubscriptionAPI.apiDef.v1).map(api => {
18
+ return {
19
+ path: api.path,
20
+ accessLevel: DefaultAccessLevel_Admin.name,
21
+ domainId: Domain_Developer._id
22
+ };
23
+ }),
24
+ { path: ApiDef_PushMessages.v1.test.path, accessLevel: DefaultAccessLevel_Admin.name, domainId: Domain_Developer._id },
25
+ { path: ApiDef_PushMessages.v1.register.path, accessLevel: DefaultAccessLevel_Active.name },
26
+ { path: ApiDef_PushMessages.v1.registerAll.path, accessLevel: DefaultAccessLevel_Active.name },
27
+ { path: ApiDef_PushMessages.v1.unregister.path, accessLevel: DefaultAccessLevel_Active.name },
28
+ ]
29
+ };
30
+ export const PermissionsDomain_PushMessages = Object.freeze(_PermissionsDomain_PushMessages);
31
+ const PermissionsGroupId_ProactivePushMessanger = '7f2c8925a6fdd2bcb9be3c1c0932deef';
32
+ const _PermissionsGroup_ProactivePushMessanger = {
33
+ _id: PermissionsGroupId_ProactivePushMessanger,
34
+ name: 'Push Messanger',
35
+ uiLabel: 'Push Messenger',
36
+ accessLevels: {
37
+ [PermissionsDomain_PushMessages.namespace]: DefaultAccessLevel_Tester.name,
38
+ }
39
+ };
40
+ export const PermissionsGroup_PushMessanger = Object.freeze(_PermissionsGroup_ProactivePushMessanger);
41
+ export const PermissionsPackage_PushMessages = {
42
+ name: PermissionsDomain_PushMessages.namespace,
43
+ domains: [PermissionsDomain_PushMessages],
44
+ groups: [PermissionsGroup_PushMessanger]
45
+ };
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './core/module-pack.js';
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /*
2
+ * A generic push pub sub infra for webapps
3
+ *
4
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ export * from './core/module-pack.js';
@@ -0,0 +1,8 @@
1
+ import { DBApiConfigV3, ModuleBE_BaseDB } from '@nu-art/thunderstorm-backend';
2
+ import { DBProto_PushMessagesHistory } from '@nu-art/push-pub-sub-shared/push-messages-history/index';
3
+ type Config = DBApiConfigV3<DBProto_PushMessagesHistory> & {};
4
+ export declare class ModuleBE_PushMessagesHistoryDB_Class extends ModuleBE_BaseDB<DBProto_PushMessagesHistory, Config> {
5
+ constructor();
6
+ }
7
+ export declare const ModuleBE_PushMessagesHistoryDB: ModuleBE_PushMessagesHistoryDB_Class;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ModuleBE_BaseDB, } from '@nu-art/thunderstorm-backend';
2
+ import { DBDef_PushMessagesHistory } from '@nu-art/push-pub-sub-shared/push-messages-history/index';
3
+ export class ModuleBE_PushMessagesHistoryDB_Class extends ModuleBE_BaseDB {
4
+ constructor() {
5
+ super(DBDef_PushMessagesHistory);
6
+ }
7
+ }
8
+ export const ModuleBE_PushMessagesHistoryDB = new ModuleBE_PushMessagesHistoryDB_Class();
@@ -0,0 +1,31 @@
1
+ import { Module } from '@nu-art/ts-common';
2
+ import { FirebaseType_BatchResponse } from '@nu-art/firebase-backend';
3
+ import { PushMessage, Request_PushRegister } from '@nu-art/push-pub-sub-shared';
4
+ import { OnCleanupSchedulerAct } from '@nu-art/thunderstorm-backend';
5
+ import { Message } from 'firebase-admin/messaging';
6
+ type Config = {
7
+ messageLengthLimit: number;
8
+ notificationsCleanupTime?: number;
9
+ sessionsCleanupTime?: number;
10
+ };
11
+ export declare class ModuleBE_PushPubSub_Class extends Module<Config> implements OnCleanupSchedulerAct {
12
+ private messaging;
13
+ constructor();
14
+ protected init(): void;
15
+ register: (body: Request_PushRegister) => Promise<void>;
16
+ pushToKey: <MessageType extends PushMessage<any, any, any>>(message: MessageType) => Promise<void>;
17
+ sendMessage: (messages: Message[]) => Promise<{
18
+ response: FirebaseType_BatchResponse;
19
+ messages: Message[];
20
+ }>;
21
+ __onCleanupSchedulerAct: () => {
22
+ cleanup: () => Promise<void>;
23
+ interval: number;
24
+ moduleKey: string;
25
+ };
26
+ scheduledCleanup: () => Promise<void>;
27
+ cleanUp: (response: FirebaseType_BatchResponse) => Promise<void>;
28
+ private cleanUpImpl;
29
+ }
30
+ export declare const ModuleBE_PushPubSub: ModuleBE_PushPubSub_Class;
31
+ export {};
@@ -0,0 +1,205 @@
1
+ /*
2
+ * A generic push pub sub infra for webapps
3
+ *
4
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { arrayToMap, batchActionParallel, compare, currentTimeMillis, Day, filterDuplicates, filterKeys, KB, LogLevel, Module } from '@nu-art/ts-common';
19
+ import { ModuleBE_Firebase } from '@nu-art/firebase-backend';
20
+ import { ApiDef_PushMessages } from '@nu-art/push-pub-sub-shared';
21
+ import { addRoutes, createBodyServerApi } from '@nu-art/thunderstorm-backend';
22
+ import { MemKey_AccountId } from '@nu-art/user-account-backend';
23
+ import { ModuleBE_PushSessionDB } from './ModuleBE_PushSessionDB.js';
24
+ import { ModuleBE_PushSubscriptionDB } from './ModuleBE_PushSubscriptionDB.js';
25
+ import { ModuleBE_PushMessagesHistoryDB } from './ModuleBE_PushMessagesHistoryDB.js';
26
+ import { HttpCodes } from '@nu-art/ts-common/core/exceptions/http-codes';
27
+ export class ModuleBE_PushPubSub_Class extends Module {
28
+ // private pushSessions!: FirestoreCollection<DB_PushSession>;
29
+ // private topics!: FirestoreCollection<DB_PushSubscription>;
30
+ messaging;
31
+ constructor() {
32
+ super();
33
+ this.setMinLevel(LogLevel.Verbose);
34
+ this.setDefaultConfig({ messageLengthLimit: 10 * KB });
35
+ }
36
+ init() {
37
+ super.init();
38
+ const session = ModuleBE_Firebase.createAdminSession();
39
+ this.messaging = session.getMessaging();
40
+ addRoutes([
41
+ createBodyServerApi(ApiDef_PushMessages.v1.test, (r) => this.pushToKey(r.message)),
42
+ createBodyServerApi(ApiDef_PushMessages.v1.register, this.register),
43
+ createBodyServerApi(ApiDef_PushMessages.v1.unregister, this.register),
44
+ createBodyServerApi(ApiDef_PushMessages.v1.registerAll, this.register)
45
+ ]);
46
+ }
47
+ register = async (body) => {
48
+ const accountId = MemKey_AccountId.get();
49
+ const session = {
50
+ firebaseToken: body.firebaseToken,
51
+ pushSessionId: body.pushSessionId,
52
+ timestamp: currentTimeMillis(),
53
+ accountId
54
+ };
55
+ await ModuleBE_PushSessionDB.set.item(session);
56
+ const subscriptions = body.subscriptions.map((subscription) => {
57
+ return filterKeys({
58
+ pushSessionId: body.pushSessionId,
59
+ ...subscription
60
+ });
61
+ });
62
+ await ModuleBE_PushSubscriptionDB.runTransaction(async (transaction) => {
63
+ const data = await ModuleBE_PushSubscriptionDB.query.where({ pushSessionId: body.pushSessionId }, transaction);
64
+ const toInsert = subscriptions.filter(s => !data.find(d => d.topic === s.topic && compare(s.filter, d.filter)));
65
+ if (toInsert.length === 0)
66
+ return;
67
+ this.logWarning(`Subscribe on: `, toInsert);
68
+ return ModuleBE_PushSubscriptionDB.create.all(toInsert, transaction);
69
+ });
70
+ };
71
+ // ---------------------------
72
+ pushToKey = async (message) => {
73
+ const originatingAccountId = MemKey_AccountId.get();
74
+ const messageLength = JSON.stringify(message).length;
75
+ if (messageLength > this.config.messageLengthLimit)
76
+ throw HttpCodes._4XX.BAD_REQUEST(`Message content too long, ${messageLength} > ${this.config.messageLengthLimit}`);
77
+ const messageSubscription = { topic: message.topic, props: message.filter };
78
+ const newVar = async (transaction) => {
79
+ let subscriptions = await ModuleBE_PushSubscriptionDB.query.where({ topic: message.topic }, transaction);
80
+ this.logVerbose(`Found ${subscriptions.length} subscribers for message: `, messageSubscription);
81
+ if (message.filter)
82
+ subscriptions = subscriptions.filter(subscription => !subscription.filter || compare(subscription.filter, message.filter));
83
+ if (subscriptions.length === 0)
84
+ return this.logDebug('No subscribers match message: ', message);
85
+ const sessionsIds = subscriptions.map(d => d.pushSessionId);
86
+ // I get the tokens relative to those sessions (query)
87
+ this.logDebug(`Sending push to:`, ` -- Sessions:`, sessionsIds, ` -- Message: `, message);
88
+ const pushSessions = await batchActionParallel(sessionsIds, 10, async (elements) => ModuleBE_PushSessionDB.query.where({ pushSessionId: { $in: elements } }, transaction));
89
+ const map_sessionIdToSession = arrayToMap(pushSessions, session => session.pushSessionId);
90
+ subscriptions = subscriptions.filter(subscription => map_sessionIdToSession[subscription.pushSessionId]);
91
+ const messagesToCreate = subscriptions.map((subscription) => {
92
+ return {
93
+ pushSessionId: subscription.pushSessionId,
94
+ token: map_sessionIdToSession[subscription.pushSessionId].firebaseToken,
95
+ message: message,
96
+ read: false,
97
+ originatingAccountId
98
+ };
99
+ });
100
+ if (messagesToCreate.length === 0)
101
+ return this.logDebug('No subscribers match message: ', message);
102
+ const dbMessages = await ModuleBE_PushMessagesHistoryDB.create.all(messagesToCreate);
103
+ const messagesToSend = dbMessages.map(dbMessage => {
104
+ const messageBody = {
105
+ _id: dbMessage._id,
106
+ timestamp: dbMessage.__created,
107
+ message: dbMessage.message,
108
+ topic: message.topic,
109
+ filter: message.filter,
110
+ };
111
+ const data = {
112
+ sessionId: dbMessage.pushSessionId,
113
+ payload: JSON.stringify(messageBody)
114
+ };
115
+ return {
116
+ token: dbMessage.token,
117
+ data: data
118
+ };
119
+ });
120
+ const { response, messages } = await this.sendMessage(messagesToSend);
121
+ this.logInfo(`${response.successCount} sent, ${response.failureCount} failed`, 'messages', messages);
122
+ // return this.cleanUp(response, messages);
123
+ };
124
+ return ModuleBE_PushSubscriptionDB.runTransaction(newVar);
125
+ };
126
+ // async pushToUser<MessageType extends PushMessage<any, any, any>>(accountId: string, message: MessageType) {
127
+ // const notification = this.buildNotification(message);
128
+ // this.logInfo(`Account ${notification.originatingAccountId} is pushing to user ${accountId}`, message.filter);
129
+ //
130
+ // const docs = await ModuleBE_PushSessionDB.query.where({accountId});
131
+ // if (docs.length === 0)
132
+ // return;
133
+ //
134
+ // const sessionsIds = docs.map(d => d.pushSessionId);
135
+ // const sessions = await batchActionParallel(sessionsIds, 10, async elements =>
136
+ // ModuleBE_PushSessionDB.query.where({pushSessionId: {$in: elements}}));
137
+ //
138
+ // const _messages = docs.reduce((carry: TempMessages, db_topic) => {
139
+ // const session = sessions.find(s => s.pushSessionId === db_topic.pushSessionId);
140
+ // if (!session)
141
+ // return carry;
142
+ //
143
+ // carry[session.firebaseToken] = [notification];
144
+ //
145
+ // return carry;
146
+ // }, {} as TempMessages);
147
+ //
148
+ // await this.sendMessage(_messages);
149
+ // }
150
+ // private buildNotification<MessageType extends PushMessage<any, any, any>>(message: MessageType) {
151
+ // const originatingAccountId = MemKey_AccountId.get();
152
+ //
153
+ // return {
154
+ // message: JSON.stringify(message),
155
+ // read: false,
156
+ // originatingAccountId
157
+ // };
158
+ // }
159
+ sendMessage = async (messages) => {
160
+ this.logInfo('sending a message to \n' + Object.keys(messages).join('\n'));
161
+ const response = await this.messaging.sendAll(messages);
162
+ this.logInfo('and this is the response: ' + response.responses.map(_response => _response.success));
163
+ return { response, messages };
164
+ };
165
+ __onCleanupSchedulerAct = () => {
166
+ return {
167
+ cleanup: this.scheduledCleanup,
168
+ interval: Day,
169
+ moduleKey: this.getName()
170
+ };
171
+ };
172
+ scheduledCleanup = async () => {
173
+ const sessionsCleanupTime = this.config?.sessionsCleanupTime || Day;
174
+ const docs = await ModuleBE_PushSessionDB.query.where({ timestamp: { $lt: currentTimeMillis() - sessionsCleanupTime } });
175
+ await Promise.all([
176
+ this.cleanUpImpl(docs.map(d => d.firebaseToken))
177
+ ]);
178
+ };
179
+ cleanUp = async (response) => {
180
+ this.logInfo(`${response.successCount} sent, ${response.failureCount} failed`);
181
+ if (response.failureCount > 0)
182
+ this.logWarning(response.responses.filter(r => r.error));
183
+ // const toDelete = response.responses.reduce((carry, resp, i) => {
184
+ // if (!resp.success && messages[i])
185
+ // carry.push(messages[i].token);
186
+ //
187
+ // return carry;
188
+ // }, [] as string[]);
189
+ //TODO: delete notifications for the user that are older than X
190
+ // return this.cleanUpImpl(toDelete); <== THIS WAS THE PROBLEM!!
191
+ };
192
+ async cleanUpImpl(_toDelete) {
193
+ if (_toDelete.length === 0)
194
+ return;
195
+ const toDelete = filterDuplicates(_toDelete);
196
+ const _sessions = await batchActionParallel(toDelete, 10, async (elements) => ModuleBE_PushSessionDB.query.where({ firebaseToken: { $in: elements } }));
197
+ const sessions = filterDuplicates(_sessions.map(s => s.pushSessionId));
198
+ const async = [
199
+ batchActionParallel(toDelete, 10, async (elements) => ModuleBE_PushSessionDB.query.where({ firebaseToken: { $in: elements } })),
200
+ batchActionParallel(sessions, 10, async (elements) => ModuleBE_PushSubscriptionDB.delete.where({ pushSessionId: { $in: elements } }))
201
+ ];
202
+ await Promise.all(async);
203
+ }
204
+ }
205
+ export const ModuleBE_PushPubSub = new ModuleBE_PushPubSub_Class();
@@ -0,0 +1,8 @@
1
+ import { DBApiConfigV3, ModuleBE_BaseDB } from '@nu-art/thunderstorm-backend';
2
+ import { DBProto_PushSession } from '@nu-art/push-pub-sub-shared/push-session/index';
3
+ type Config = DBApiConfigV3<DBProto_PushSession> & {};
4
+ export declare class ModuleBE_PushSessionDB_Class extends ModuleBE_BaseDB<DBProto_PushSession, Config> {
5
+ constructor();
6
+ }
7
+ export declare const ModuleBE_PushSessionDB: ModuleBE_PushSessionDB_Class;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ModuleBE_BaseDB, } from '@nu-art/thunderstorm-backend';
2
+ import { DBDef_PushSession } from '@nu-art/push-pub-sub-shared/push-session/index';
3
+ export class ModuleBE_PushSessionDB_Class extends ModuleBE_BaseDB {
4
+ constructor() {
5
+ super(DBDef_PushSession);
6
+ }
7
+ }
8
+ export const ModuleBE_PushSessionDB = new ModuleBE_PushSessionDB_Class();
@@ -0,0 +1,9 @@
1
+ import { DBApiConfigV3, ModuleBE_BaseDB } from '@nu-art/thunderstorm-backend';
2
+ import { DBProto_PushSubscription } from '@nu-art/push-pub-sub-shared/push-subscription/index';
3
+ type Config = DBApiConfigV3<DBProto_PushSubscription> & {};
4
+ export declare class ModuleBE_PushSubscriptionDB_Class extends ModuleBE_BaseDB<DBProto_PushSubscription, Config> {
5
+ constructor();
6
+ }
7
+ export declare const ModuleBE_PushSubscriptionDB: ModuleBE_PushSubscriptionDB_Class;
8
+ export declare const ModuleBE_PushSubscriptionAPI: import("@nu-art/thunderstorm-backend").ModuleBE_BaseApi_Class<DBProto_PushSubscription>;
9
+ export {};
@@ -0,0 +1,9 @@
1
+ import { createApisForDBModuleV3, ModuleBE_BaseDB, } from '@nu-art/thunderstorm-backend';
2
+ import { DBDef_PushSubscription } from '@nu-art/push-pub-sub-shared/push-subscription/index';
3
+ export class ModuleBE_PushSubscriptionDB_Class extends ModuleBE_BaseDB {
4
+ constructor() {
5
+ super(DBDef_PushSubscription);
6
+ }
7
+ }
8
+ export const ModuleBE_PushSubscriptionDB = new ModuleBE_PushSubscriptionDB_Class();
9
+ export const ModuleBE_PushSubscriptionAPI = createApisForDBModuleV3(ModuleBE_PushSubscriptionDB);
@@ -0,0 +1,6 @@
1
+ import { PushMessage } from '@nu-art/push-pub-sub-shared';
2
+ export declare class PushKey_BE<MessageType extends PushMessage<any, any, any>> {
3
+ private readonly topic;
4
+ constructor(topic: MessageType['topic']);
5
+ push(data: MessageType['data'], filter?: MessageType['filter']): Promise<void>;
6
+ }
@@ -0,0 +1,27 @@
1
+ /*
2
+ * A generic push pub sub infra for webapps
3
+ *
4
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { ModuleBE_PushPubSub } from './ModuleBE_PushPubSub.js';
19
+ export class PushKey_BE {
20
+ topic;
21
+ constructor(topic) {
22
+ this.topic = topic;
23
+ }
24
+ async push(data, filter) {
25
+ return ModuleBE_PushPubSub.pushToKey({ topic: this.topic, filter, data });
26
+ }
27
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@nu-art/push-pub-sub-backend",
3
+ "version": "0.400.7",
4
+ "description": "push-pub-sub Backend",
5
+ "keywords": [
6
+ "TacB0sS",
7
+ "express",
8
+ "infra",
9
+ "nu-art",
10
+ "push-pub-sub",
11
+ "thunderstorm",
12
+ "typescript"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+ssh://git@github.com:nu-art-js/push-pub-sub.git"
17
+ },
18
+ "publishConfig": {
19
+ "directory": "dist",
20
+ "linkDirectory": true
21
+ },
22
+ "license": "Apache-2.0",
23
+ "author": "TacB0sS",
24
+ "scripts": {
25
+ "build": "tsc -b -f"
26
+ },
27
+ "dependencies": {
28
+ "@nu-art/push-pub-sub-shared": "0.400.7",
29
+ "@nu-art/firebase-backend": "0.400.7",
30
+ "@nu-art/firebase-shared": "0.400.7",
31
+ "@nu-art/permissions-backend": "0.400.7",
32
+ "@nu-art/permissions-shared": "0.400.7",
33
+ "@nu-art/thunderstorm-backend": "0.400.7",
34
+ "@nu-art/thunderstorm-shared": "0.400.7",
35
+ "@nu-art/ts-common": "0.400.7",
36
+ "@nu-art/user-account-backend": "0.400.7",
37
+ "@nu-art/user-account-shared": "0.400.7",
38
+ "firebase": "^11.9.0",
39
+ "firebase-admin": "13.4.0",
40
+ "moment": "^2.29.4",
41
+ "react": "^18.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/react": "^18.0.0"
45
+ },
46
+ "unitConfig": {
47
+ "type": "typescript-lib"
48
+ },
49
+ "type": "module",
50
+ "exports": {
51
+ ".": {
52
+ "types": "./index.d.ts",
53
+ "import": "./index.js"
54
+ },
55
+ "./*": {
56
+ "types": "./*.d.ts",
57
+ "import": "./*.js"
58
+ }
59
+ }
60
+ }