feat(static): fmt
这个提交包含在:
@@ -5,6 +5,7 @@
|
|||||||
同时提供简单的静态文件服务。
|
同时提供简单的静态文件服务。
|
||||||
|
|
||||||
## images
|
## images
|
||||||
|
|
||||||
https://hub.docker.com/u/devcm
|
https://hub.docker.com/u/devcm
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
@@ -9,5 +9,11 @@
|
|||||||
},
|
},
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"start": "deno run --allow-net --allow-read --allow-sys --allow-env main.ts"
|
"start": "deno run --allow-net --allow-read --allow-sys --allow-env main.ts"
|
||||||
|
},
|
||||||
|
"fmt": {
|
||||||
|
"lineWidth": 120,
|
||||||
|
"indentWidth": 2,
|
||||||
|
"semiColons": true,
|
||||||
|
"singleQuote": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ enum Headers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CodeMessageMap: Record<number, string> = {
|
const CodeMessageMap: Record<number, string> = {
|
||||||
403: '禁止访问此内容: 抱歉,由于安全问题您被禁止访问此内容。如果您认为这是个错误,请联系我们获取帮助。',
|
403: "禁止访问此内容: 抱歉,由于安全问题您被禁止访问此内容。如果您认为这是个错误,请联系我们获取帮助。",
|
||||||
404: '内容未找到: 您正在寻找的内容可能已被删除、名称已更改或暂时不可用。',
|
404: "内容未找到: 您正在寻找的内容可能已被删除、名称已更改或暂时不可用。",
|
||||||
429: '请求过多: 由于请求过多,您的请求已被限制。请稍后刷新页面重试。',
|
429: "请求过多: 由于请求过多,您的请求已被限制。请稍后刷新页面重试。",
|
||||||
500: '服务器错误: 请稍后再试,或者返回主页。如果问题持续存在,请联系我们,我们会尽快修复。'
|
500: "服务器错误: 请稍后再试,或者返回主页。如果问题持续存在,请联系我们,我们会尽快修复。",
|
||||||
};
|
};
|
||||||
|
|
||||||
// 默认处理函数
|
// 默认处理函数
|
||||||
@@ -72,23 +72,15 @@ server.all("/", (request, reply) => {
|
|||||||
const isCodeExist = Reflect.has(CodeMessageMap, code);
|
const isCodeExist = Reflect.has(CodeMessageMap, code);
|
||||||
|
|
||||||
if (!isCodeExist) {
|
if (!isCodeExist) {
|
||||||
const codeList = Object.keys(CodeMessageMap).map(Number).sort((a, b) =>
|
const codeList = Object.keys(CodeMessageMap).map(Number).sort((a, b) => a - b);
|
||||||
a - b
|
compatibleCode = Number(codeList.find((c) => String(c).startsWith(String(code).charAt(0))) || 404);
|
||||||
);
|
|
||||||
compatibleCode = Number(
|
|
||||||
codeList.find((c) => String(c).startsWith(String(code).charAt(0))) || 404,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = CodeMessageMap[compatibleCode];
|
const message = CodeMessageMap[compatibleCode];
|
||||||
|
|
||||||
const data = { code, requestId, message };
|
const data = { code, requestId, message };
|
||||||
|
|
||||||
console.log(
|
console.log(`[${new Date().toISOString()}] code:${code} url:'${originalURI}' ext:'${ext}' requestId:'${requestId}'`);
|
||||||
`[${
|
|
||||||
new Date().toISOString()
|
|
||||||
}] code:${code} url:'${originalURI}' ext:'${ext}' requestId:'${requestId}'`,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 根据后缀渲染不同的内容
|
// 根据后缀渲染不同的内容
|
||||||
if (ext === ".html" || ext === ".htm") {
|
if (ext === ".html" || ext === ".htm") {
|
||||||
|
|||||||
在新议题中引用
屏蔽一个用户