@rpcbase/server 0.234.0 → 0.236.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
CHANGED
|
@@ -48,7 +48,7 @@ const reset_password = async({email}, ctx) => {
|
|
|
48
48
|
|
|
49
49
|
await reset_token.save()
|
|
50
50
|
|
|
51
|
-
const reset_url = `https://${APP_DOMAIN}/set-new-password?
|
|
51
|
+
const reset_url = `https://${APP_DOMAIN}/set-new-password?uid=${user._id}&token=${token}`
|
|
52
52
|
|
|
53
53
|
const res = await mailer.sendEmail({
|
|
54
54
|
From: MAILER_FROM_EMAIL,
|
|
@@ -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({
|