@rpcbase/server 0.387.0 → 0.388.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/package.json +3 -2
- package/src/initServer.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.388.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"connect-redis": "8.0.1",
|
|
28
28
|
"express-session": "1.18.1",
|
|
29
|
-
"redis": "4.7.0"
|
|
29
|
+
"redis": "4.7.0",
|
|
30
|
+
"request-ip": "3.3.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {}
|
|
32
33
|
}
|
package/src/initServer.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Application } from "express"
|
|
|
2
2
|
import session, { SessionOptions } from "express-session"
|
|
3
3
|
import {RedisStore} from "connect-redis"
|
|
4
4
|
import {createClient} from "redis"
|
|
5
|
+
import requestIp from "request-ip"
|
|
5
6
|
|
|
6
7
|
import { getDerivedKey } from "./getDerivedKey"
|
|
7
8
|
|
|
@@ -11,6 +12,10 @@ const isProduction = process.env.NODE_ENV === "production"
|
|
|
11
12
|
export const initServer = async (app: Application, serverEnv: { [key: string]: string | undefined }) => {
|
|
12
13
|
app.disable("x-powered-by")
|
|
13
14
|
|
|
15
|
+
app.set("trust proxy", true)
|
|
16
|
+
|
|
17
|
+
app.use(requestIp.mw())
|
|
18
|
+
|
|
14
19
|
const sessionSecret = getDerivedKey(serverEnv.MASTER_KEY!, "express_session_key")
|
|
15
20
|
|
|
16
21
|
const reconnectStrategy = (retries: number) => {
|