@web-ts-toolkit/message-service 0.29.0 → 0.31.0
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.
- package/README.md +25 -7
- package/package.json +3 -7
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ Peer dependencies:
|
|
|
28
28
|
## Quick Start
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
|
+
import express from 'express';
|
|
31
32
|
import mongoose from 'mongoose';
|
|
32
33
|
import {
|
|
33
34
|
buildMessageArchiveSchema,
|
|
@@ -41,6 +42,9 @@ import {
|
|
|
41
42
|
MessageTemplate,
|
|
42
43
|
} from '@web-ts-toolkit/message-service';
|
|
43
44
|
|
|
45
|
+
const app = express();
|
|
46
|
+
const myAuthMiddleware: express.RequestHandler = (_req, _res, next) => next();
|
|
47
|
+
|
|
44
48
|
await mongoose.connect('mongodb://localhost/mydb');
|
|
45
49
|
|
|
46
50
|
mongoose.model(MESSAGE_MODEL_NAME, buildMessageSchema());
|
|
@@ -191,9 +195,13 @@ The route factory translates these to 404/400/403 HTTP responses via `@web-ts-to
|
|
|
191
195
|
```typescript
|
|
192
196
|
import { EmailProvider } from '@web-ts-toolkit/message-service';
|
|
193
197
|
|
|
198
|
+
async function sendWithProvider(to: string, subject: string, text: string): Promise<void> {
|
|
199
|
+
void { to, subject, text };
|
|
200
|
+
}
|
|
201
|
+
|
|
194
202
|
class SendGridEmailProvider implements EmailProvider {
|
|
195
203
|
async sendNotification(to: string, title: string, body: string) {
|
|
196
|
-
await
|
|
204
|
+
await sendWithProvider(to, title, body);
|
|
197
205
|
}
|
|
198
206
|
}
|
|
199
207
|
```
|
|
@@ -205,18 +213,28 @@ Pass it to `buildMessageSchema({ emailNotifier: provider.sendNotification.bind(p
|
|
|
205
213
|
```typescript
|
|
206
214
|
import { PaymentProvider } from '@web-ts-toolkit/message-service';
|
|
207
215
|
|
|
216
|
+
async function createCheckoutSession(user: unknown, code: string, priceArgs: unknown): Promise<string> {
|
|
217
|
+
void { user, code, priceArgs };
|
|
218
|
+
return 'session_123';
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
async function expireCheckoutSession(sessionId: string): Promise<void> {
|
|
222
|
+
void sessionId;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async function refundCheckoutSession(sessionId: string): Promise<void> {
|
|
226
|
+
void sessionId;
|
|
227
|
+
}
|
|
228
|
+
|
|
208
229
|
class StripePaymentProvider implements PaymentProvider {
|
|
209
230
|
async createSession(user, code, priceArgs) {
|
|
210
|
-
|
|
211
|
-
/* ... */
|
|
212
|
-
});
|
|
213
|
-
return session.id;
|
|
231
|
+
return await createCheckoutSession(user, code, priceArgs);
|
|
214
232
|
}
|
|
215
233
|
async expireSession(sessionId) {
|
|
216
|
-
await
|
|
234
|
+
await expireCheckoutSession(sessionId);
|
|
217
235
|
}
|
|
218
236
|
async refundPayment(sessionId) {
|
|
219
|
-
await
|
|
237
|
+
await refundCheckoutSession(sessionId);
|
|
220
238
|
}
|
|
221
239
|
}
|
|
222
240
|
```
|
package/package.json
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
"name": "@web-ts-toolkit/message-service",
|
|
3
3
|
"description": "Template-driven messaging core for Mongoose + Express applications",
|
|
4
4
|
"homepage": "https://web-ts-toolkit.pages.dev/docs/packages/message-service",
|
|
5
|
-
"version": "0.
|
|
6
|
-
"sideEffects": [
|
|
7
|
-
"./dist/schemas/message.js",
|
|
8
|
-
"./dist/schemas/message-archive.js"
|
|
9
|
-
],
|
|
5
|
+
"version": "0.31.0",
|
|
10
6
|
"keywords": [
|
|
11
7
|
"mongoose",
|
|
12
8
|
"messaging",
|
|
@@ -30,8 +26,8 @@
|
|
|
30
26
|
"node": ">=20"
|
|
31
27
|
},
|
|
32
28
|
"dependencies": {
|
|
33
|
-
"@web-ts-toolkit/express-json-router": "0.
|
|
34
|
-
"@web-ts-toolkit/utils": "0.
|
|
29
|
+
"@web-ts-toolkit/express-json-router": "0.31.0",
|
|
30
|
+
"@web-ts-toolkit/utils": "0.31.0",
|
|
35
31
|
"handlebars": "^4.7.8"
|
|
36
32
|
},
|
|
37
33
|
"peerDependencies": {
|