@rpcbase/server 0.387.0 → 0.389.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 +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.389.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
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { Application } from "express"
|
|
2
|
+
import dotenv from "dotenv"
|
|
2
3
|
import session, { SessionOptions } from "express-session"
|
|
3
4
|
import {RedisStore} from "connect-redis"
|
|
4
5
|
import {createClient} from "redis"
|
|
6
|
+
import requestIp from "request-ip"
|
|
7
|
+
|
|
8
|
+
// dotenv setup, merge process env with vite process.env file
|
|
9
|
+
process.env = {
|
|
10
|
+
...process.env,
|
|
11
|
+
...dotenv.config().parsed
|
|
12
|
+
}
|
|
5
13
|
|
|
6
14
|
import { getDerivedKey } from "./getDerivedKey"
|
|
7
15
|
|
|
@@ -11,6 +19,10 @@ const isProduction = process.env.NODE_ENV === "production"
|
|
|
11
19
|
export const initServer = async (app: Application, serverEnv: { [key: string]: string | undefined }) => {
|
|
12
20
|
app.disable("x-powered-by")
|
|
13
21
|
|
|
22
|
+
app.set("trust proxy", true)
|
|
23
|
+
|
|
24
|
+
app.use(requestIp.mw())
|
|
25
|
+
|
|
14
26
|
const sessionSecret = getDerivedKey(serverEnv.MASTER_KEY!, "express_session_key")
|
|
15
27
|
|
|
16
28
|
const reconnectStrategy = (retries: number) => {
|