@rpcbase/server 0.233.0 → 0.235.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 +1 -1
- package/src/auth/sign_up.js +1 -1
- package/src/client/client_router.js +16 -34
- package/src/sessions/index.js +1 -1
package/package.json
CHANGED
package/src/auth/sign_up.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
+
const assert = require("assert")
|
|
2
3
|
const fs = require("fs")
|
|
3
4
|
const path = require("path")
|
|
4
5
|
const glob = require("glob")
|
|
@@ -7,19 +8,20 @@ const Sentry = require("@sentry/node")
|
|
|
7
8
|
const async_wrapper = require("../helpers/async_wrapper")
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
+
const MIME_TYPES = {
|
|
11
12
|
".css": "text/css",
|
|
12
13
|
".js": "text/javascript",
|
|
13
14
|
".json": "application/json",
|
|
14
15
|
".svg": "image/svg+xml",
|
|
16
|
+
".woff2": "font/woff2",
|
|
17
|
+
".png": "image/png",
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
const {SENTRY_DSN, NODE_ENV} = process.env
|
|
18
21
|
const has_sentry = !!SENTRY_DSN
|
|
19
22
|
|
|
20
23
|
const is_development = NODE_ENV === "development"
|
|
21
|
-
|
|
22
|
-
const COMPRESSED_EXTENSIONS = is_development ? [] : Object.keys(COMPRESSED_EXTENSIONS_MAP)
|
|
24
|
+
|
|
23
25
|
|
|
24
26
|
const src_path = path.join(process.cwd(), "./src/")
|
|
25
27
|
const build_dir = path.join(process.cwd(), "build/")
|
|
@@ -41,38 +43,17 @@ const get_client_routes = () => {
|
|
|
41
43
|
const serve_file = (req, res, full_path) => {
|
|
42
44
|
const file_path = path.join(client_build_dir, full_path)
|
|
43
45
|
|
|
44
|
-
const extname = path.extname(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"Content-Encoding": "br",
|
|
54
|
-
"Content-Type": COMPRESSED_EXTENSIONS_MAP[extname],
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
// gzip
|
|
59
|
-
else if (!is_development && accept_encoding.indexOf("gzip") > -1) {
|
|
60
|
-
res.sendFile(`${file_path}.gz`, {
|
|
61
|
-
headers: {
|
|
62
|
-
"Content-Encoding": "gzip",
|
|
63
|
-
"Content-Type": COMPRESSED_EXTENSIONS_MAP[extname],
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
// unknown accept-encoding
|
|
68
|
-
else {
|
|
69
|
-
res.sendFile(file_path)
|
|
46
|
+
const extname = path.extname(file_path)
|
|
47
|
+
|
|
48
|
+
const content_type = MIME_TYPES[extname]
|
|
49
|
+
assert(content_type, "unable to resolve content type")
|
|
50
|
+
|
|
51
|
+
res.sendFile(file_path, {
|
|
52
|
+
headers: {
|
|
53
|
+
"Cache-Control": `public, max-age=1800`, // 30 mins
|
|
54
|
+
"Content-Type": content_type,
|
|
70
55
|
}
|
|
71
|
-
}
|
|
72
|
-
// not compressed
|
|
73
|
-
else {
|
|
74
|
-
res.sendFile(file_path)
|
|
75
|
-
}
|
|
56
|
+
})
|
|
76
57
|
}
|
|
77
58
|
|
|
78
59
|
|
|
@@ -112,6 +93,7 @@ const client_router = (app) => {
|
|
|
112
93
|
}
|
|
113
94
|
|
|
114
95
|
|
|
96
|
+
// TODO: this should not be here
|
|
115
97
|
app.use((err, req, res, next) => {
|
|
116
98
|
console.error("server got err", err)
|
|
117
99
|
res.status(500).json({
|
package/src/sessions/index.js
CHANGED
|
@@ -13,7 +13,7 @@ module.exports = (app) => {
|
|
|
13
13
|
const session_store_middleware = require("./session_store_middleware")
|
|
14
14
|
app.use(session_store_middleware)
|
|
15
15
|
} else {
|
|
16
|
-
console.log("using", pc.bold(pc.red("REVERSE-PROXY SESSIONS")), "if you want to use the session store, start with the --sessions argument")
|
|
16
|
+
console.log("using", pc.bold(pc.red("REVERSE-PROXY SESSIONS!")), "if you want to use the session store, start with the --sessions argument")
|
|
17
17
|
|
|
18
18
|
// warn the user
|
|
19
19
|
if (is_development) {
|