@rpcbase/server 0.451.0 → 0.452.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/dist/email.d.ts +19 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -9
- package/package.json +3 -2
package/dist/email.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type SendEmailParams = {
|
|
2
|
+
to: string | string[];
|
|
3
|
+
subject: string;
|
|
4
|
+
html?: string;
|
|
5
|
+
text?: string;
|
|
6
|
+
from?: string;
|
|
7
|
+
replyTo?: string | string[];
|
|
8
|
+
};
|
|
9
|
+
export declare const sendEmail: (params: SendEmailParams) => Promise<{
|
|
10
|
+
id: undefined;
|
|
11
|
+
skipped: boolean;
|
|
12
|
+
error?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
id: string | undefined;
|
|
15
|
+
error: string | undefined;
|
|
16
|
+
skipped: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../src/email.ts"],"names":[],"mappings":"AAGA,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC7B,CAAA;AAKD,eAAO,MAAM,SAAS,GAAS,QAAQ,eAAe;;;;;;;;EAsBrD,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { StrictMode, createElement } from "react";
|
|
|
17
17
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
18
18
|
import { jsx } from "react/jsx-runtime";
|
|
19
19
|
import { createPath, matchRoutes, parsePath, createStaticRouter, StaticRouterProvider } from "@rpcbase/router";
|
|
20
|
+
import { Resend } from "resend";
|
|
20
21
|
function getDefaultExportFromCjs(x) {
|
|
21
22
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
22
23
|
}
|
|
@@ -822,14 +823,14 @@ function isPostHogFetchContentTooLargeError(err) {
|
|
|
822
823
|
return "object" == typeof err && err instanceof PostHogFetchHttpError && 413 === err.status;
|
|
823
824
|
}
|
|
824
825
|
class PostHogCoreStateless {
|
|
825
|
-
constructor(
|
|
826
|
+
constructor(apiKey2, options = {}) {
|
|
826
827
|
this.flushPromise = null;
|
|
827
828
|
this.shutdownPromise = null;
|
|
828
829
|
this.promiseQueue = new PromiseQueue();
|
|
829
830
|
this._events = new SimpleEventEmitter();
|
|
830
831
|
this._isInitialized = false;
|
|
831
|
-
assert(
|
|
832
|
-
this.apiKey =
|
|
832
|
+
assert(apiKey2, "You must pass your PostHog project's api key.");
|
|
833
|
+
this.apiKey = apiKey2;
|
|
833
834
|
this.host = removeTrailingSlash(options.host || "https://us.i.posthog.com");
|
|
834
835
|
this.flushAt = options.flushAt ? Math.max(options.flushAt, 1) : 20;
|
|
835
836
|
this.maxBatchSize = Math.max(this.flushAt, options.maxBatchSize ?? 100);
|
|
@@ -2674,8 +2675,8 @@ const MINIMUM_POLLING_INTERVAL = 100;
|
|
|
2674
2675
|
const THIRTY_SECONDS = 3e4;
|
|
2675
2676
|
const MAX_CACHE_SIZE = 5e4;
|
|
2676
2677
|
class PostHogBackendClient extends PostHogCoreStateless {
|
|
2677
|
-
constructor(
|
|
2678
|
-
super(
|
|
2678
|
+
constructor(apiKey2, options = {}) {
|
|
2679
|
+
super(apiKey2, options), this._memoryStorage = new PostHogMemoryStorage();
|
|
2679
2680
|
this.options = options;
|
|
2680
2681
|
this.context = this.initializeContext();
|
|
2681
2682
|
this.options.featureFlagsPollingInterval = "number" == typeof options.featureFlagsPollingInterval ? Math.max(options.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
|
|
@@ -2685,7 +2686,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
2685
2686
|
if (shouldEnableLocalEvaluation) this.featureFlagsPoller = new FeatureFlagsPoller({
|
|
2686
2687
|
pollingInterval: this.options.featureFlagsPollingInterval,
|
|
2687
2688
|
personalApiKey: options.personalApiKey,
|
|
2688
|
-
projectApiKey:
|
|
2689
|
+
projectApiKey: apiKey2,
|
|
2689
2690
|
timeout: options.requestTimeout ?? 1e4,
|
|
2690
2691
|
host: this.host,
|
|
2691
2692
|
fetch: options.fetch,
|
|
@@ -3209,12 +3210,12 @@ const resolveApiKey = (env2) => env2.POSTHOG_API_KEY || env2.POSTHOG_KEY || env2
|
|
|
3209
3210
|
const resolveHost = (env2) => env2.POSTHOG_HOST || env2.RB_POSTHOG_HOST || "https://eu.i.posthog.com";
|
|
3210
3211
|
const getPosthogClient = (env2) => {
|
|
3211
3212
|
if (client !== void 0) return client;
|
|
3212
|
-
const
|
|
3213
|
-
if (!
|
|
3213
|
+
const apiKey2 = resolveApiKey(env2);
|
|
3214
|
+
if (!apiKey2) {
|
|
3214
3215
|
client = null;
|
|
3215
3216
|
return client;
|
|
3216
3217
|
}
|
|
3217
|
-
client = new PostHog(
|
|
3218
|
+
client = new PostHog(apiKey2, {
|
|
3218
3219
|
host: resolveHost(env2),
|
|
3219
3220
|
enableExceptionAutocapture: true,
|
|
3220
3221
|
flushAt: 1,
|
|
@@ -3769,9 +3770,32 @@ const ssrMiddleware = ({
|
|
|
3769
3770
|
finalizeWithErrorPage(err);
|
|
3770
3771
|
}
|
|
3771
3772
|
};
|
|
3773
|
+
const apiKey = process.env.RESEND_API_KEY;
|
|
3774
|
+
const defaultFrom = process.env.RESEND_FROM || "hello@rpcbase.com";
|
|
3775
|
+
const sendEmail = async (params) => {
|
|
3776
|
+
if (!apiKey) {
|
|
3777
|
+
console.warn("RESEND_API_KEY not set, skipping email");
|
|
3778
|
+
return { id: void 0, skipped: true };
|
|
3779
|
+
}
|
|
3780
|
+
const resend = new Resend(apiKey);
|
|
3781
|
+
const response = await resend.emails.send({
|
|
3782
|
+
from: params.from || defaultFrom,
|
|
3783
|
+
to: params.to,
|
|
3784
|
+
subject: params.subject,
|
|
3785
|
+
html: params.html,
|
|
3786
|
+
text: params.text,
|
|
3787
|
+
replyTo: params.replyTo
|
|
3788
|
+
});
|
|
3789
|
+
return {
|
|
3790
|
+
id: response.data?.id,
|
|
3791
|
+
error: response.error?.message,
|
|
3792
|
+
skipped: false
|
|
3793
|
+
};
|
|
3794
|
+
};
|
|
3772
3795
|
export {
|
|
3773
3796
|
getDerivedKey,
|
|
3774
3797
|
hashPassword,
|
|
3775
3798
|
initServer,
|
|
3799
|
+
sendEmail,
|
|
3776
3800
|
ssrMiddleware
|
|
3777
3801
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.452.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
"connect-redis": "9.0.0",
|
|
50
50
|
"express-session": "1.18.2",
|
|
51
51
|
"http-proxy-middleware": "3.0.5",
|
|
52
|
-
"redis": "5.10.0"
|
|
52
|
+
"redis": "5.10.0",
|
|
53
|
+
"resend": "6.5.2"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"request-ip": "3.3.0"
|