Browse Source

更新环境变量示例,新增 HTTPS_ENABLE 配置;优化 VSCode 设置,增强代码提示和调试体验;修正中间件导入路径,调整会话中间件的安全配置

re
谢亚昕 3 months ago
parent
commit
6bd82d5da6
  1. 3
      .env.example
  2. 2
      .vscode/DEBUG.md
  3. 5
      .vscode/extensions.json
  4. 25
      .vscode/launch.json
  5. 34
      .vscode/settings.json
  6. 2
      src/middlewares/Session/index.js
  7. 2
      src/middlewares/install.js

3
.env.example

@ -1 +1,2 @@
SESSION_SECRET=随机字符串 SESSION_SECRET=随机字符串
HTTPS_ENABLE=on

2
.vscode/DEBUG.md

@ -0,0 +1,2 @@
https://blog.csdn.net/gitblog_00813/article/details/150962609

5
.vscode/extensions.json

@ -0,0 +1,5 @@
{
"recommendations": [
"oven.bun-vscode"
]
}

25
.vscode/launch.json

@ -0,0 +1,25 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "bun",
"request": "launch",
"name": "Debug Bun File",
"program": "${cwd}/src/main.js",
"cwd": "${workspaceFolder}",
"env": {},
"stopOnEntry": false,
"watchMode": false,
"noDebug": false,
"runtimeArgs": []
},
{
"type": "bun",
"request": "attach",
"name": "Attach to Bun Process",
"url": "ws://localhost:6499/",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
]
}

34
.vscode/settings.json

@ -1,3 +1,35 @@
{ {
"CodeFree.index": true "typescript.preferences.includePackageJsonAutoImports": "auto",
"javascript.preferences.includePackageJsonAutoImports": "auto",
"typescript.suggest.autoImports": true,
"javascript.suggest.autoImports": true,
"typescript.updateImportsOnFileMove.enabled": "always",
"javascript.updateImportsOnFileMove.enabled": "always",
"files.associations": {
"*.pug": "pug"
},
"emmet.includeLanguages": {
"pug": "html"
},
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/logs": true,
"**/database": true,
"**/public/uploads": true
},
"files.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/logs": true,
"**/database": true,
"**/public/uploads": true
},
"debug.console.fontSize": 14,
"debug.console.lineHeight": 20,
"debug.inlineValues": "auto",
"debug.showBreakpointsInOverviewRuler": true,
"debug.showInlineBreakpointCandidates": true,
"bun.enable": true,
"bun.path": "bun"
} }

2
src/middlewares/Session/index.js

@ -8,7 +8,7 @@ export default (app) => {
signed: true, // 将 cookie 的内容通过密钥进行加密。需配置app.keys signed: true, // 将 cookie 的内容通过密钥进行加密。需配置app.keys
rolling: false, rolling: false,
renew: false, renew: false,
secure: process.env.NODE_ENV === "production", secure: process.env.NODE_ENV === "production" && process.env.HTTPS_ENABLE === "on",
sameSite: "lax", // https://scotthelme.co.uk/csrf-is-dead/ sameSite: "lax", // https://scotthelme.co.uk/csrf-is-dead/
}; };
return session(CONFIG, app); return session(CONFIG, app);

2
src/middlewares/install.js

@ -3,7 +3,7 @@ import Send from "./Send"
import { resolve } from "path" import { resolve } from "path"
import { fileURLToPath } from "url" import { fileURLToPath } from "url"
import path from "path" import path from "path"
import ErrorHandler from "./errorHandler" import ErrorHandler from "./ErrorHandler"
import { Auth } from "./Auth" import { Auth } from "./Auth"
import bodyParser from "koa-bodyparser" import bodyParser from "koa-bodyparser"
import Views from "./Views" import Views from "./Views"

Loading…
Cancel
Save