@waline/vercel 1.27.1 → 1.28.0-alpha.1
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
package/src/config/middleware.js
CHANGED
|
@@ -6,23 +6,28 @@ const isTcb = think.env === 'cloudbase';
|
|
|
6
6
|
const isDeta = think.env === 'deta' || process.env.DETA_RUNTIME === 'true';
|
|
7
7
|
const isAliyunFC =
|
|
8
8
|
think.env === 'aliyun-fc' || Boolean(process.env.FC_RUNTIME_VERSION);
|
|
9
|
+
const isNetlify = process.env.NETLIFY_IMAGES_CDN_DOMAIN && process.env._HANDLER;
|
|
10
|
+
const netlifyFunctionPrefix = `/.netlify/functions/${process.env._HANDLER.replace(
|
|
11
|
+
/\.handler$/,
|
|
12
|
+
''
|
|
13
|
+
)}`;
|
|
9
14
|
|
|
10
15
|
module.exports = [
|
|
11
16
|
{
|
|
12
17
|
handle: 'dashboard',
|
|
13
|
-
match: /^\/ui/,
|
|
18
|
+
match: isNetlify ? new RegExp(`${netlifyFunctionPrefix}/ui`, 'i') : /^\/ui/,
|
|
14
19
|
},
|
|
15
20
|
|
|
16
21
|
{
|
|
17
22
|
handle: 'prefix-warning',
|
|
18
23
|
},
|
|
19
|
-
|
|
20
24
|
{
|
|
21
25
|
handle: 'meta',
|
|
22
26
|
options: {
|
|
23
27
|
logRequest: isDev,
|
|
24
28
|
sendResponseTime: isDev,
|
|
25
|
-
requestTimeoutCallback:
|
|
29
|
+
requestTimeoutCallback:
|
|
30
|
+
isTcb || isDeta || isAliyunFC || isNetlify ? false : () => {},
|
|
26
31
|
},
|
|
27
32
|
},
|
|
28
33
|
|
|
@@ -62,7 +67,7 @@ module.exports = [
|
|
|
62
67
|
{
|
|
63
68
|
handle: 'router',
|
|
64
69
|
options: {
|
|
65
|
-
prefix: ['/api']
|
|
70
|
+
prefix: ['/api', netlifyFunctionPrefix, `${netlifyFunctionPrefix}/api`],
|
|
66
71
|
},
|
|
67
72
|
},
|
|
68
73
|
|
|
@@ -171,7 +171,10 @@ module.exports = class extends BaseRest {
|
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
if (
|
|
174
|
+
if (
|
|
175
|
+
Array.isArray(url) &&
|
|
176
|
+
(url.length > 1 || !this.ctx.state.deprecated)
|
|
177
|
+
) {
|
|
175
178
|
const data = await this.modelInstance.select(where, {
|
|
176
179
|
field: ['url'],
|
|
177
180
|
});
|
|
@@ -339,7 +342,10 @@ module.exports = class extends BaseRest {
|
|
|
339
342
|
(cmt) => rootIds[cmt.objectId] || rootIds[cmt.rid]
|
|
340
343
|
);
|
|
341
344
|
} else {
|
|
342
|
-
comments = await this.modelInstance.select(
|
|
345
|
+
comments = await this.modelInstance.select(
|
|
346
|
+
{ ...where, rid: undefined },
|
|
347
|
+
{ ...selectOptions }
|
|
348
|
+
);
|
|
343
349
|
rootCount = comments.length;
|
|
344
350
|
rootComments = [
|
|
345
351
|
...comments.filter(({ rid, sticky }) => !rid && sticky),
|
|
@@ -449,7 +455,17 @@ module.exports = class extends BaseRest {
|
|
|
449
455
|
cmt.children = await Promise.all(
|
|
450
456
|
comments
|
|
451
457
|
.filter(({ rid }) => rid === cmt.objectId)
|
|
452
|
-
.map((cmt) =>
|
|
458
|
+
.map((cmt) =>
|
|
459
|
+
formatCmt(
|
|
460
|
+
cmt,
|
|
461
|
+
users,
|
|
462
|
+
{
|
|
463
|
+
...this.config(),
|
|
464
|
+
deprecated: this.ctx.state.deprecated,
|
|
465
|
+
},
|
|
466
|
+
userInfo
|
|
467
|
+
)
|
|
468
|
+
)
|
|
453
469
|
.reverse()
|
|
454
470
|
);
|
|
455
471
|
|
|
@@ -6,13 +6,21 @@ const DEPRECATE_ROUTER_NEXT_VERSION = [
|
|
|
6
6
|
'/user',
|
|
7
7
|
'/verification',
|
|
8
8
|
'/token/2fa',
|
|
9
|
-
'/user/password'
|
|
9
|
+
'/user/password',
|
|
10
10
|
];
|
|
11
11
|
|
|
12
12
|
module.exports = () => async (ctx, next) => {
|
|
13
|
-
ctx.state.deprecated = DEPRECATE_ROUTER_NEXT_VERSION.some(
|
|
13
|
+
ctx.state.deprecated = DEPRECATE_ROUTER_NEXT_VERSION.some((prefix) => {
|
|
14
|
+
const oldAPI = new RegExp(`${prefix}$`, 'i');
|
|
15
|
+
const newAPI = new RegExp(`/api${prefix}$`, 'i');
|
|
16
|
+
|
|
17
|
+
return !newAPI.test(ctx.path) && oldAPI.test(ctx.path);
|
|
18
|
+
});
|
|
19
|
+
|
|
14
20
|
if (ctx.state.deprecated) {
|
|
15
|
-
think.logger.warn(
|
|
21
|
+
think.logger.warn(
|
|
22
|
+
`[Deprecated] ${ctx.path} API will be deprecated in the next major version, please don't use it anymore. If you are using \`@waline/client\` please upgrade to \`@waline/client@3\`. For other scenarios, you can use \`/api${ctx.path}\` to replace it.`
|
|
23
|
+
);
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
await next();
|