@rpcbase/server 0.546.0 → 0.547.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/index.js +9 -17
- package/dist/index.js.map +1 -1
- package/dist/initServer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createClient } from "redis";
|
|
|
5
5
|
import { MongoClient } from "mongodb";
|
|
6
6
|
import env from "@rpcbase/env";
|
|
7
7
|
import { initApiClient, STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY, RtsSsrRuntimeProvider, SsrErrorFallback, SSR_ERROR_STATE_GLOBAL_KEY, serializeSsrErrorState } from "@rpcbase/client";
|
|
8
|
+
import { getMongoUrl } from "@rpcbase/db/mongo";
|
|
8
9
|
import { posix, dirname, sep } from "path";
|
|
9
10
|
import fs, { createReadStream, readFileSync } from "node:fs";
|
|
10
11
|
import { createInterface } from "node:readline";
|
|
@@ -3981,26 +3982,17 @@ process.env = {
|
|
|
3981
3982
|
};
|
|
3982
3983
|
const isProduction$1 = process.env.NODE_ENV === "production";
|
|
3983
3984
|
const SESSION_MAX_AGE_S = 3600 * 24 * 60;
|
|
3984
|
-
const
|
|
3985
|
-
const
|
|
3986
|
-
if (
|
|
3987
|
-
|
|
3985
|
+
const getMongoSessionUrl = (serverEnv) => {
|
|
3986
|
+
const appName = serverEnv.APP_NAME?.trim();
|
|
3987
|
+
if (!appName) {
|
|
3988
|
+
throw new Error("Missing APP_NAME (required to build MongoDB session store DB name)");
|
|
3988
3989
|
}
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
if (!appName) {
|
|
3993
|
-
throw new Error("Missing APP_NAME (required to build MongoDB session store DB name)");
|
|
3994
|
-
}
|
|
3995
|
-
return `mongodb://${host}:${serverEnv.DB_PORT}/${appName}-sessions`;
|
|
3996
|
-
}
|
|
3997
|
-
return void 0;
|
|
3990
|
+
return getMongoUrl(serverEnv, {
|
|
3991
|
+
dbName: `${appName}-sessions`
|
|
3992
|
+
});
|
|
3998
3993
|
};
|
|
3999
3994
|
const createMongoSessionStore = async (serverEnv) => {
|
|
4000
|
-
const mongoUrl =
|
|
4001
|
-
if (!mongoUrl) {
|
|
4002
|
-
throw new Error("Missing REDIS_URL and Mongo connection details (MONGODB_URL/MONGO_URL/MONGODB_URI/DB_PORT)");
|
|
4003
|
-
}
|
|
3995
|
+
const mongoUrl = getMongoSessionUrl(serverEnv);
|
|
4004
3996
|
console.log("Using MongoDB session store");
|
|
4005
3997
|
const client2 = await MongoClient.connect(mongoUrl, {
|
|
4006
3998
|
family: 4,
|