@blocklet/sdk 1.16.15-beta-e4ad74af → 1.16.15-beta-e143b1cf
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.
|
@@ -12,7 +12,7 @@ const fallback = (file, options = {}) => {
|
|
|
12
12
|
if ((0, fs_1.existsSync)(filePath) === false) {
|
|
13
13
|
throw new Error(`Fallback file not found at: ${filePath}`);
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
const sourceRaw = (0, fs_1.readFileSync)(filePath).toString();
|
|
16
16
|
return async (req, res, next) => {
|
|
17
17
|
if ((req.method === 'GET' || req.method === 'HEAD') && req.accepts('html')) {
|
|
18
18
|
res.type('html');
|
|
@@ -20,7 +20,8 @@ const fallback = (file, options = {}) => {
|
|
|
20
20
|
const pageData = typeof options.getPageData === 'function' ? await options.getPageData(req) : {};
|
|
21
21
|
pageData.title = (0, escape_1.default)(pageData.title || config_1.env.appName);
|
|
22
22
|
pageData.description = (0, escape_1.default)(pageData.description || config_1.env.appDescription);
|
|
23
|
-
pageData.ogImage =
|
|
23
|
+
pageData.ogImage = pageData.ogImage || (0, url_join_1.default)(config_1.env.appUrl || '/', '/.well-known/service/blocklet/og.png');
|
|
24
|
+
let source = sourceRaw.slice(0);
|
|
24
25
|
// inject seo title
|
|
25
26
|
if (pageData.title) {
|
|
26
27
|
if (source.indexOf('<title>') === -1) {
|
|
@@ -52,6 +53,10 @@ const fallback = (file, options = {}) => {
|
|
|
52
53
|
.replace('<script src="__blocklet__.js"></script>', `<script>${blockletJs}</script>`)
|
|
53
54
|
.replace('<script src="__meta__.js"></script>', `<script>${blockletJs}</script>`);
|
|
54
55
|
}
|
|
56
|
+
// disable cache for generated html
|
|
57
|
+
res.setHeader('Surrogate-Control', 'no-store');
|
|
58
|
+
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
|
|
59
|
+
res.setHeader('Expires', '0');
|
|
55
60
|
res.send(source);
|
|
56
61
|
// istanbul-ignore-next
|
|
57
62
|
if (process.env.NODE_ENV === 'test') {
|
|
@@ -26,8 +26,6 @@ declare const _default: {
|
|
|
26
26
|
verifySig: (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: import("express").Response<any, Record<string, any>>, next: import("express").NextFunction) => void | import("express").Response<any, Record<string, any>>;
|
|
27
27
|
};
|
|
28
28
|
fallback: (file: string, options?: {
|
|
29
|
-
cacheControl?: boolean;
|
|
30
|
-
maxAge?: string | number;
|
|
31
29
|
root?: string;
|
|
32
30
|
getPageData?: (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>) => Promise<{
|
|
33
31
|
title?: string;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.15-beta-
|
|
6
|
+
"version": "1.16.15-beta-e143b1cf",
|
|
7
7
|
"description": "graphql client to read/write data on abt node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"typings": "lib/index.d.ts",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@abtnode/client": "1.16.
|
|
30
|
-
"@abtnode/constant": "1.16.
|
|
29
|
+
"@abtnode/client": "1.16.15-beta-e143b1cf",
|
|
30
|
+
"@abtnode/constant": "1.16.15-beta-e143b1cf",
|
|
31
31
|
"@arcblock/did": "1.18.89",
|
|
32
32
|
"@arcblock/did-auth": "1.18.89",
|
|
33
33
|
"@arcblock/jwt": "1.18.89",
|
|
34
34
|
"@arcblock/ws": "1.18.89",
|
|
35
|
-
"@blocklet/constant": "1.16.
|
|
36
|
-
"@blocklet/env": "1.16.
|
|
37
|
-
"@blocklet/meta": "1.16.
|
|
35
|
+
"@blocklet/constant": "1.16.15-beta-e143b1cf",
|
|
36
|
+
"@blocklet/env": "1.16.15-beta-e143b1cf",
|
|
37
|
+
"@blocklet/meta": "1.16.15-beta-e143b1cf",
|
|
38
38
|
"@did-connect/authenticator": "^2.2.0",
|
|
39
39
|
"@did-connect/handler": "^2.2.0",
|
|
40
40
|
"@nedb/core": "^2.1.5",
|
|
@@ -73,5 +73,6 @@
|
|
|
73
73
|
"ts-jest": "^27.1.5",
|
|
74
74
|
"ts-node": "^10.9.1",
|
|
75
75
|
"typescript": "^5.0.4"
|
|
76
|
-
}
|
|
76
|
+
},
|
|
77
|
+
"gitHead": "86dcc908f3cb7259d1ca92b9ae75160a6e43509a"
|
|
77
78
|
}
|