diff --git a/astro.config.ts b/astro.config.ts index 5d08f53..ad7146b 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -31,6 +31,7 @@ export default defineConfig({ // Artalk Comment ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }), }, + validateSecrets: true, }, }, integrations: [ diff --git a/package-lock.json b/package-lock.json index d72d1b7..4a3cd18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@astrojs/mdx": "^3.1.2", "@astrojs/node": "^8.3.2", "@astrojs/rss": "^4.0.7", - "astro": "^4.11.5", + "astro": "^4.11.6", "drizzle-orm": "^0.32.0", "fuse.js": "^7.0.0", "lodash": "^4.17.21", @@ -23,12 +23,12 @@ "ultrahtml": "^1.5.3" }, "devDependencies": { - "@astrojs/check": "^0.8.1", + "@astrojs/check": "^0.8.2", "@biomejs/biome": "^1.8.3", "@napi-rs/canvas": "^0.1.53", "@types/lodash": "^4.17.7", "@types/luxon": "^3.4.2", - "@types/node": "^20.14.10", + "@types/node": "^20.14.11", "@types/pg": "^8.11.6", "@types/qrcode-svg": "^1.1.4", "@types/unist": "^3.0.2", @@ -36,7 +36,7 @@ "astro-uploader": "^1.1.3", "bootstrap": "^5.3.3", "prettier": "^3.3.3", - "prettier-plugin-astro": "^0.14.0", + "prettier-plugin-astro": "^0.14.1", "prettier-plugin-astro-organize-imports": "^0.4.9", "prettier-plugin-organize-imports": "^4.0.0", "rehype-external-links": "^3.0.0", @@ -61,13 +61,13 @@ } }, "node_modules/@astrojs/check": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@astrojs/check/-/check-0.8.1.tgz", - "integrity": "sha512-QTzCuiBWll3SLSe7OsWtWyZRbwChXwxM4Y0Jb84jdPOdYobzHad9ubU7V23qmK3Y0BNwgzCbEP5C5FPVitb31Q==", + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@astrojs/check/-/check-0.8.2.tgz", + "integrity": "sha512-L0V9dGb2PGvK9Mf3kby99Y+qm7EqxaC9tN1MVCvaqp/3pPPZBadR4XAySHipxXqQsxwJS25WQow8/1kMl1e25g==", "dev": true, "license": "MIT", "dependencies": { - "@astrojs/language-server": "^2.11.1", + "@astrojs/language-server": "^2.12.1", "chokidar": "^3.5.3", "fast-glob": "^3.3.1", "kleur": "^4.1.5", @@ -81,9 +81,9 @@ } }, "node_modules/@astrojs/compiler": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.8.2.tgz", - "integrity": "sha512-2v2N2oDnMH6+CX1Wn6f45Afa4tdkUMutdx8pJaokfaOYnAU+u6+UK7o7sXqydKro1cLwVmmOIJv6AqiXnAdLDA==", + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.9.2.tgz", + "integrity": "sha512-Vpu0Ffsj8SoV+N0DFHlxxOMKHwSC9059Xy/OlG1t6uFYSoJXxkBC2WyF6igO7x10V+8uJrhOxaXr3nA90kJXow==", "license": "MIT" }, "node_modules/@astrojs/internal-helpers": { @@ -93,13 +93,13 @@ "license": "MIT" }, "node_modules/@astrojs/language-server": { - "version": "2.11.1", - "resolved": "https://registry.npmjs.org/@astrojs/language-server/-/language-server-2.11.1.tgz", - "integrity": "sha512-WSIBBUK9lSeVD4KhPiZk2u3wsXdj7WEYvYPPs8ZsgbSVIOzUJWAKVcITHiXmcXlzZB5ubK44YUN/Hq+f2GeMyQ==", + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/@astrojs/language-server/-/language-server-2.12.1.tgz", + "integrity": "sha512-CCibE6XwSmrZEKlPDr48LZJN7NWxOurOJK1yOzqZFMNV8Y6DIqF6s1e60gbNNHMZkthWYBNTPno4Ni/XyviinQ==", "dev": true, "license": "MIT", "dependencies": { - "@astrojs/compiler": "^2.7.0", + "@astrojs/compiler": "^2.9.1", "@jridgewell/sourcemap-codec": "^1.4.15", "@volar/kit": "~2.4.0-alpha.15", "@volar/language-core": "~2.4.0-alpha.15", @@ -303,9 +303,9 @@ } }, "node_modules/@babel/generator": { - "version": "7.24.9", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.9.tgz", - "integrity": "sha512-G8v3jRg+z8IwY1jHFxvCNhOPYPterE4XljNgdGTYfSTtzzwjIswIzIaSPSLs3R7yFuqnqNeay5rjICfqVr+/6A==", + "version": "7.24.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.10.tgz", + "integrity": "sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==", "license": "MIT", "dependencies": { "@babel/types": "^7.24.9", @@ -1699,6 +1699,19 @@ "node": ">=12" } }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/@isaacs/cliui/node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -1724,6 +1737,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", @@ -2509,9 +2540,9 @@ } }, "node_modules/@types/node": { - "version": "20.14.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", - "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", "devOptional": true, "license": "MIT", "dependencies": { @@ -2821,27 +2852,27 @@ } }, "node_modules/astro": { - "version": "4.11.5", - "resolved": "https://registry.npmjs.org/astro/-/astro-4.11.5.tgz", - "integrity": "sha512-TCRhuaLwrxwMhS8S1GG+ZTdrAXigX9C8E/YUTs/r2t+owHxDgwl86IV9xH1IHrCPoqhK6civyAQNOT+GKmkb0A==", + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/astro/-/astro-4.11.6.tgz", + "integrity": "sha512-h2n8tJJrexuIVbeceQDxPJv+0D9sDUqiN5K2Ao7akkpxslllpsa5f5aIsLHKKVD2xAwgDIhGTzkm8pn40Im6Cw==", "license": "MIT", "dependencies": { - "@astrojs/compiler": "^2.8.1", + "@astrojs/compiler": "^2.8.2", "@astrojs/internal-helpers": "0.4.1", "@astrojs/markdown-remark": "5.1.1", "@astrojs/telemetry": "3.1.0", - "@babel/core": "^7.24.7", - "@babel/generator": "^7.24.7", - "@babel/parser": "^7.24.7", + "@babel/core": "^7.24.9", + "@babel/generator": "^7.24.10", + "@babel/parser": "^7.24.8", "@babel/plugin-transform-react-jsx": "^7.24.7", - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7", + "@babel/traverse": "^7.24.8", + "@babel/types": "^7.24.9", "@types/babel__core": "^7.20.5", "@types/cookie": "^0.6.0", - "acorn": "^8.12.0", + "acorn": "^8.12.1", "aria-query": "^5.3.0", - "axobject-query": "^4.0.0", - "boxen": "^7.1.1", + "axobject-query": "^4.1.0", + "boxen": "^8.0.0", "chokidar": "^3.6.0", "ci-info": "^4.0.0", "clsx": "^2.1.1", @@ -2869,22 +2900,22 @@ "magic-string": "^0.30.10", "mrmime": "^2.0.0", "ora": "^8.0.1", - "p-limit": "^5.0.0", + "p-limit": "^6.1.0", "p-queue": "^8.0.1", "path-to-regexp": "^6.2.2", - "preferred-pm": "^3.1.3", + "preferred-pm": "^4.0.0", "prompts": "^2.4.2", "rehype": "^13.0.1", "semver": "^7.6.2", - "shiki": "^1.10.0", + "shiki": "^1.10.3", "string-width": "^7.2.0", "strip-ansi": "^7.1.0", "tsconfck": "^3.1.1", "unist-util-visit": "^5.0.0", - "vfile": "^6.0.1", - "vite": "^5.3.2", + "vfile": "^6.0.2", + "vite": "^5.3.4", "vitefu": "^0.2.5", - "which-pm": "^2.2.0", + "which-pm": "^3.0.0", "yargs-parser": "^21.1.1", "zod": "^3.23.8", "zod-to-json-schema": "^3.23.1" @@ -3088,22 +3119,22 @@ } }, "node_modules/boxen": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/boxen/-/boxen-7.1.1.tgz", - "integrity": "sha512-2hCgjEmP8YLWQ130n2FerGv7rYpfBmnmp9Uy2Le1vge6X3gZIfSmEzP5QTDElFxcvVcXlEn8Aq6MU/PZygIOog==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-8.0.0.tgz", + "integrity": "sha512-Mzw0gi6A0zH9bVVLSuoyaPFbae4gv3luQkkt3FmVgA1g/oeKpqxFII39OuV58AiwcN2FR+rwlZhJ2mfggjEWKw==", "license": "MIT", "dependencies": { "ansi-align": "^3.0.1", - "camelcase": "^7.0.1", - "chalk": "^5.2.0", - "cli-boxes": "^3.0.0", - "string-width": "^5.1.2", - "type-fest": "^2.13.0", - "widest-line": "^4.0.1", - "wrap-ansi": "^8.1.0" + "camelcase": "^8.0.0", + "chalk": "^5.3.0", + "cli-boxes": "^4.0.0", + "string-width": "^7.2.0", + "type-fest": "^4.21.0", + "widest-line": "^5.0.0", + "wrap-ansi": "^9.0.0" }, "engines": { - "node": ">=14.16" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -3121,29 +3152,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/boxen/node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "license": "MIT" - }, - "node_modules/boxen/node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "license": "MIT", - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -3199,12 +3207,12 @@ } }, "node_modules/camelcase": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.1.tgz", - "integrity": "sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-8.0.0.tgz", + "integrity": "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==", "license": "MIT", "engines": { - "node": ">=14.16" + "node": ">=16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -3334,12 +3342,12 @@ } }, "node_modules/cli-boxes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-3.0.0.tgz", - "integrity": "sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-4.0.0.tgz", + "integrity": "sha512-RU4tOq6V6/HggQwAumv7c8O2tuvg0gElkQ5FEdWULl4itMhvgqy1kWXq5oy3FbKOF65Ml8J4lxWbHDZcKaWLQA==", "license": "MIT", "engines": { - "node": ">=10" + "node": ">=18.20" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -3887,6 +3895,7 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, "license": "MIT" }, "node_modules/ee-first": { @@ -3896,9 +3905,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.4.828", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.828.tgz", - "integrity": "sha512-QOIJiWpQJDHAVO4P58pwb133Cwee0nbvy/MV1CwzZVGpkH1RX33N3vsaWRCpR6bF63AAq366neZrRTu7Qlsbbw==", + "version": "1.4.829", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.829.tgz", + "integrity": "sha512-5qp1N2POAfW0u1qGAxXEtz6P7bO1m6gpZr5hdf5ve6lxpLM7MpiM4jIPz7xcrNlClQMafbyUDDWjlIQZ1Mw0Rw==", "license": "ISC" }, "node_modules/emmet": { @@ -4219,16 +4228,25 @@ } }, "node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "license": "MIT", "dependencies": { - "locate-path": "^6.0.0", + "locate-path": "^5.0.0", "path-exists": "^4.0.0" }, "engines": { - "node": ">=10" + "node": ">=8" + } + }, + "node_modules/find-up-simple": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/find-up-simple/-/find-up-simple-1.0.0.tgz", + "integrity": "sha512-q7Us7kcjj2VMePAa02hDAF6d+MzsdsAWEwYyOpwUtlerRBkOEPBCRZrAV4XfcSN8fHAgaD0hP7miwoay6DCprw==", + "license": "MIT", + "engines": { + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -5124,18 +5142,15 @@ } }, "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "license": "MIT", "dependencies": { - "p-locate": "^5.0.0" + "p-locate": "^4.1.0" }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=8" } }, "node_modules/lodash": { @@ -6422,9 +6437,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", - "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.17.tgz", + "integrity": "sha512-Ww6ZlOiEQfPfXM45v17oabk77Z7mg5bOt7AjDyzy7RjK9OrLrLC8dyZQoAPEOtFX9SaNf1Tdvr5gRJWdTJj7GA==", "license": "MIT" }, "node_modules/normalize-path": { @@ -6565,12 +6580,12 @@ } }, "node_modules/p-limit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-5.0.0.tgz", - "integrity": "sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.1.0.tgz", + "integrity": "sha512-H0jc0q1vOzlEk0TqAKXKZxdl7kX3OFUzCnNVUnq5Pc3DGo0kpeaMuPqxQn235HibwBEb0/pm9dgKTjXy66fBkg==", "license": "MIT", "dependencies": { - "yocto-queue": "^1.0.0" + "yocto-queue": "^1.1.1" }, "engines": { "node": ">=18" @@ -6580,42 +6595,27 @@ } }, "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "license": "MIT", "dependencies": { - "p-limit": "^3.0.2" + "p-limit": "^2.2.0" }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=8" } }, "node_modules/p-locate/node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "license": "MIT", "dependencies": { - "yocto-queue": "^0.1.0" + "p-try": "^2.0.0" }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-locate/node_modules/yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "license": "MIT", - "engines": { - "node": ">=10" + "node": ">=6" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -6986,58 +6986,6 @@ "node": ">=8" } }, - "node_modules/pkg-dir/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "license": "MIT", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "license": "MIT", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "license": "MIT", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pkg-dir/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/postcss": { "version": "8.4.39", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.39.tgz", @@ -7117,18 +7065,17 @@ "license": "MIT" }, "node_modules/preferred-pm": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/preferred-pm/-/preferred-pm-3.1.4.tgz", - "integrity": "sha512-lEHd+yEm22jXdCphDrkvIJQU66EuLojPPtvZkpKIkiD+l0DMThF/niqZKJSoU8Vl7iuvtmzyMhir9LdVy5WMnA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/preferred-pm/-/preferred-pm-4.0.0.tgz", + "integrity": "sha512-gYBeFTZLu055D8Vv3cSPox/0iTPtkzxpLroSYYA7WXgRi31WCJ51Uyl8ZiPeUUjyvs2MBzK+S8v9JVUgHU/Sqw==", "license": "MIT", "dependencies": { - "find-up": "^5.0.0", + "find-up-simple": "^1.0.0", "find-yarn-workspace-root2": "1.2.16", - "path-exists": "^4.0.0", - "which-pm": "^2.2.0" + "which-pm": "^3.0.0" }, "engines": { - "node": ">=10" + "node": ">=18.12" } }, "node_modules/prettier": { @@ -7148,13 +7095,13 @@ } }, "node_modules/prettier-plugin-astro": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/prettier-plugin-astro/-/prettier-plugin-astro-0.14.0.tgz", - "integrity": "sha512-7jRGJsexaRIyUzTk8uzXlP45cw6DQ5Ci4bTe0xCBCcuO1Fff8jJy9oI+kRCQKSdDFTSAArMSg8GpvzlKBtSaZA==", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-astro/-/prettier-plugin-astro-0.14.1.tgz", + "integrity": "sha512-RiBETaaP9veVstE4vUwSIcdATj6dKmXljouXc/DDNwBSPTp8FRkLGDSGFClKsAFeeg+13SB0Z1JZvbD76bigJw==", "dev": true, "license": "MIT", "dependencies": { - "@astrojs/compiler": "^1.5.5", + "@astrojs/compiler": "^2.9.1", "prettier": "^3.0.0", "sass-formatter": "^0.7.6" }, @@ -7186,13 +7133,6 @@ } } }, - "node_modules/prettier-plugin-astro/node_modules/@astrojs/compiler": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-1.8.2.tgz", - "integrity": "sha512-o/ObKgtMzl8SlpIdzaxFnt7SATKPxu4oIP/1NL+HDJRzxfJcAkOTAb/ZKMRyULbz4q+1t2/DAebs2Z1QairkZw==", - "dev": true, - "license": "MIT" - }, "node_modules/prettier-plugin-organize-imports": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-4.0.0.tgz", @@ -7736,9 +7676,9 @@ } }, "node_modules/semver": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", - "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -8249,12 +8189,12 @@ "optional": true }, "node_modules/type-fest": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", - "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "version": "4.22.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.22.0.tgz", + "integrity": "sha512-hxMO1k4ip1uTVGgPbs1hVpYyhz2P91A6tQyH2H9POx3U6T3MdhIcfY8L2hRu/LRmzPFdfduOS0RIDjFlP2urPw==", "license": "(MIT OR CC0-1.0)", "engines": { - "node": ">=12.20" + "node": ">=16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -8508,9 +8448,9 @@ } }, "node_modules/vfile": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", - "integrity": "sha512-1bYqc7pt6NIADBJ98UiG0Bn/CHIVOoZ/IyEkqIruLg0mE1BKzkOXY2D6CSqQIcKqgadppE5lrxgWXJmXd7zZJw==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.2.tgz", + "integrity": "sha512-zND7NlS8rJYb/sPqkb13ZvbbUoExdbi4w3SfRrMq6R3FvnLQmmfpajJNITuuYm6AZ5uao9vy4BAos3EXBPf2rg==", "license": "MIT", "dependencies": { "@types/unist": "^3.0.0", @@ -8551,9 +8491,9 @@ } }, "node_modules/vite": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.3.tgz", - "integrity": "sha512-NPQdeCU0Dv2z5fu+ULotpuq5yfCS1BzKUIPhNbP3YBfAMGJXbt2nS+sbTFu+qchaqWTD+H3JK++nRwr6XIcp6A==", + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.4.tgz", + "integrity": "sha512-Cw+7zL3ZG9/NZBB8C+8QbQZmR54GwqIz+WMI4b3JgdYJvX+ny9AjJXqkGQlDXSXRP9rP0B4tbciRMOVEKulVOA==", "license": "MIT", "dependencies": { "esbuild": "^0.21.3", @@ -8857,16 +8797,15 @@ } }, "node_modules/which-pm": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/which-pm/-/which-pm-2.2.0.tgz", - "integrity": "sha512-MOiaDbA5ZZgUjkeMWM5EkJp4loW5ZRoa5bc3/aeMox/PJelMhE6t7S/mLuiY43DBupyxH+S0U1bTui9kWUlmsw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/which-pm/-/which-pm-3.0.0.tgz", + "integrity": "sha512-ysVYmw6+ZBhx3+ZkcPwRuJi38ZOTLJJ33PSHaitLxSKUMsh0LkKd0nC69zZCwt5D+AYUcMK2hhw4yWny20vSGg==", "license": "MIT", "dependencies": { - "load-yaml-file": "^0.2.0", - "path-exists": "^4.0.0" + "load-yaml-file": "^0.2.0" }, "engines": { - "node": ">=8.15" + "node": ">=18.12" } }, "node_modules/which-pm-runs": { @@ -8879,55 +8818,32 @@ } }, "node_modules/widest-line": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-4.0.1.tgz", - "integrity": "sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-5.0.0.tgz", + "integrity": "sha512-c9bZp7b5YtRj2wOe6dlj32MK+Bx/M/d+9VB2SHM1OtsUHR0aV0tdP6DWh/iMt0kWi1t5g1Iudu6hQRNd1A4PVA==", "license": "MIT", "dependencies": { - "string-width": "^5.0.1" + "string-width": "^7.0.0" }, "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/widest-line/node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "license": "MIT" - }, - "node_modules/widest-line/node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "license": "MIT", - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz", + "integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==", "license": "MIT", "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" }, "engines": { - "node": ">=12" + "node": ">=18" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" @@ -9045,29 +8961,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/wrap-ansi/node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "license": "MIT" - }, - "node_modules/wrap-ansi/node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "license": "MIT", - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index d464cf1..745c5f5 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@astrojs/mdx": "^3.1.2", "@astrojs/node": "^8.3.2", "@astrojs/rss": "^4.0.7", - "astro": "^4.11.5", + "astro": "^4.11.6", "drizzle-orm": "^0.32.0", "fuse.js": "^7.0.0", "lodash": "^4.17.21", @@ -55,12 +55,12 @@ "ultrahtml": "^1.5.3" }, "devDependencies": { - "@astrojs/check": "^0.8.1", + "@astrojs/check": "^0.8.2", "@biomejs/biome": "^1.8.3", "@napi-rs/canvas": "^0.1.53", "@types/lodash": "^4.17.7", "@types/luxon": "^3.4.2", - "@types/node": "^20.14.10", + "@types/node": "^20.14.11", "@types/pg": "^8.11.6", "@types/qrcode-svg": "^1.1.4", "@types/unist": "^3.0.2", @@ -68,7 +68,7 @@ "astro-uploader": "^1.1.3", "bootstrap": "^5.3.3", "prettier": "^3.3.3", - "prettier-plugin-astro": "^0.14.0", + "prettier-plugin-astro": "^0.14.1", "prettier-plugin-astro-organize-imports": "^0.4.9", "prettier-plugin-organize-imports": "^4.0.0", "rehype-external-links": "^3.0.0", diff --git a/src/content/posts/2015/2015-09-06-we-are-stranger.mdx b/src/content/posts/2015/2015-09-06-we-are-stranger.mdx index 9b0cfeb..648e67c 100644 --- a/src/content/posts/2015/2015-09-06-we-are-stranger.mdx +++ b/src/content/posts/2015/2015-09-06-we-are-stranger.mdx @@ -16,9 +16,9 @@ summary: 还未从忙碌中回神,八月就这么不知不觉地过去,周 ——题记 -今年的八月,没有去年那般湿热,不知是不是因为毕业的日子早已离我远去,印象中 里 的毕业季总是在热火朝天的季节里,热得烦躁不堪却也要坚持穿上累赘的学士服四处拍照。就和初到北京时住的地下室一样,湿漉漉的地板墙壁,湿漉漉的被单床铺,像是初面职场时内心焦急的大汗淋漓。 +今年的八月,没有去年那般湿热,不知是不是因为毕业的日子早已离我远去,印象中的毕业季总是在热火朝天的季节里,热得烦躁不堪却也要坚持穿上累赘的学士服四处拍照。就和初到北京时住的地下室一样,湿漉漉的地板墙壁,湿漉漉的被单床铺,像是初面职场时内心焦急的大汗淋漓。 -那时的我,面对着陌生的职场,从来没接触的知识和技能,内心焦躁不安并自我怀疑。那样烦躁的日子里,睡前唯一能做的事,就是强迫自己阅读几页《 Java 编程思想》,每多掌握一点知识的时候,心中的焦虑便会被抚平一些。后来习惯了在公司通宵加班,大多时候,其实都是在看书,看设计模式,看关系数据库,看 NoSQL ,看并发编程…… +那时的我,面对着陌生的职场,从来没接触的知识和技能,内心焦躁不安并自我怀疑。那样烦躁的日子里,睡前唯一能做的事,就是强迫自己阅读几页《Java 编程思想》,每多掌握一点知识的时候,心中的焦虑便会被抚平一些。后来习惯了在公司通宵加班,大多时候,其实都是在看书,看设计模式,看关系数据库,看 NoSQL ,看并发编程…… 看了那么多还是看不清前路,公司的休息室睡起来不是很舒适,每每梦里迷迷糊糊好像看见许多面孔,醒来却头沉沉什么都想不起来。却又总会莫名其妙回想起很多旧时的事儿:六岁那年那只追着我三条街的狗;中秋节的外婆牌麻糍;爷爷去世时躺的那块旧门板。 @@ -34,7 +34,7 @@ summary: 还未从忙碌中回神,八月就这么不知不觉地过去,周 领导对自己的不信任,同事对自己的抱怨,让自己一度绝望想要放弃。那时的我一个人负责全部项目的技术重构设计,项目组只有一个新入职的产品,一个才毕业的测试。全部的需求要我带着去过,测试也要我手把手教,代码只有我一个人写。算不清喝了多少咖啡,回家的次数也屈指可数。 -记得有一次凌晨 4 点, Review 完明天要上线的代码,我却不知道该做什么好,就这么静静地坐到天亮,动都不想动。窗外,是一成不变的灯红酒绿,屋内,却是一片漆黑。我看着屏幕上的那个自己,陌生、迷茫…… +记得有一次凌晨 4 点,Review 完明天要上线的代码,我却不知道该做什么好,就这么静静地坐到天亮,动都不想动。窗外,是一成不变的灯红酒绿,屋内,却是一片漆黑。我看着屏幕上的那个自己,陌生、迷茫…… ![この瞬間だけは汚れた街もマシになる](/images/2023/12/2023120213392110.jpg) diff --git a/src/content/posts/2015/2015-12-08-rest-api-desgin.mdx b/src/content/posts/2015/2015-12-08-rest-api-desgin.mdx index 9568f3a..b5ac1dc 100644 --- a/src/content/posts/2015/2015-12-08-rest-api-desgin.mdx +++ b/src/content/posts/2015/2015-12-08-rest-api-desgin.mdx @@ -40,7 +40,7 @@ Rest API,无论它的名字多么高大上,它本质还是一个 HTTP 请求 `API`设计时常会考虑版本这个概念,无论是在URI还是在请求参数里面,至少有一个地方得指明含版本,为什么呢? -这很简单,就和系统迭代一样,API也是快速迭代开发的。也许初期,你的老大脑袋一热,我们要上API,于是你们就加班加点做,设定了一版请求协议。当时你们想,写完就能赚钱,必然带来一堆问题,比如说,代码难以维护,功能单一。后面这个`API`的第二版,你们要基于它去做一些新的变更,比如请求参数多了,返回内容多了,必然就有了第二版。但是又不能影响现有的业务。这个`API`基本的`URI`没变,但是会同时存在两个版本,老用户继续请求旧版,没问题,你无需动旧版?有需求的新用户,你要请求新版才能提供服务。这样通过版本来区分了不同的服务,便于以后的升级和维护。_(就像BAE那货可以毫无压力地废弃掉2.0的API)_ +这很简单,就和系统迭代一样,API也是快速迭代开发的。也许初期,你的老大脑袋一热,我们要上 API,于是你们就加班加点做,设定了一版请求协议。当时你们想,写完就能赚钱,必然带来一堆问题,比如说,代码难以维护,功能单一。后面这个`API`的第二版,你们要基于它去做一些新的变更,比如请求参数多了,返回内容多了,必然就有了第二版。但是又不能影响现有的业务。这个 `API` 基本的 `URI` 没变,但是会同时存在两个版本,老用户继续请求旧版,没问题,你无需动旧版?有需求的新用户,你要请求新版才能提供服务。这样通过版本来区分了不同的服务,便于以后的升级和维护。_(就像 BAE 那货可以毫无压力地废弃掉 2.0 的API)_ **所以一开始设计API时,就要定义好版本。其次,版本化可以骗钱。** 我们可以满怀恶意地猜测,1.0为了抢用户,免费。2.0老牛逼了,你用的爽了,想更爽,付费。233333333 @@ -66,63 +66,63 @@ PS,实际的架构远比这个复杂,截图选自《大型网站系统与Jav **1、演变** -初期的API平台往往是上图左侧那种,某个庞大的业务系统希望暴露一套API,于是大家就在这个系统上做,直接设计一套协议。但是,这样子带来的缺点十分明显,第一,它与业务联系太重,理想的API平台是通用的,不是只给你设计一个。第二,它不好扩展,每次变更都得和业务系统一同上线,糟糕的情况下代码还会影响原有正常的业务。第三,性能问题,理论上会降低原有应用的性能。 +初期的 API 平台往往是上图左侧那种,某个庞大的业务系统希望暴露一套 API,于是大家就在这个系统上做,直接设计一套协议。但是,这样子带来的缺点十分明显,第一,它与业务联系太重,理想的API平台是通用的,不是只给你设计一个。第二,它不好扩展,每次变更都得和业务系统一同上线,糟糕的情况下代码还会影响原有正常的业务。第三,性能问题,理论上会降低原有应用的性能。 -这种情况下,如果应用部署了多台机器,多个节点,我们就可以独立出来。也就是右边所示的API Gateway,它做的事情本质上就是反向代理,将外部的请求校验完合法性之后反代至内部实际想要对外暴露服务的服务集群上。 +这种情况下,如果应用部署了多台机器,多个节点,我们就可以独立出来。也就是右边所示的 API Gateway,它做的事情本质上就是反向代理,将外部的请求校验完合法性之后反代至内部实际想要对外暴露服务的服务集群上。 -所以,这种场景下,API Gateway也就如名称所说,就是一个入口。实际的Rest API的东西还是建立在各个业务子系统上,只是只需要提供最简单的服务,无需考虑授权等东西。用户管理,API注册发布,调用统计等,均由API Gateway实现处理。对于想要快速上线的开发人员而言,实在是一个不错的福音。 +所以,这种场景下,API Gateway 也就如名称所说,就是一个入口。实际的 Rest API 的东西还是建立在各个业务子系统上,只是只需要提供最简单的服务,无需考虑授权等东西。用户管理,API注册发布,调用统计等,均由 API Gateway 实现处理。对于想要快速上线的开发人员而言,实在是一个不错的福音。 -然而,当系统应用拆分到了SOA化之后,API的架构由有了新的变革,我们有了注册中心的概念。因为SOA化,所以每个业务子系统其实都有了对外的统一接口,有了ESB(注册中心)。实际的内部系统间请求也有了较好的路由、熔断等策略。 +然而,当系统应用拆分到了 SOA 化之后,API 的架构由有了新的变革,我们有了注册中心的概念。因为 SOA 化,所以每个业务子系统其实都有了对外的统一接口,有了 ESB(注册中心)。实际的内部系统间请求也有了较好的路由、熔断等策略。 -在这种大背景下,API平台对外暴露的Rest API无需底层的业务专门开发了。直接使用现有的内部接口,选择性暴露即可。问题点就在于,如何根据定义的Rest API请求,实际模拟内部的RPC协议请求。 +在这种大背景下,API 平台对外暴露的 Rest API 无需底层的业务专门开发了。直接使用现有的内部接口,选择性暴露即可。问题点就在于,如何根据定义的Rest API请求,实际模拟内部的RPC协议请求。 -某种程度上,这时候的API平台,已经不仅仅是HTTP Rest请求了。我们完全可以实现相同RPC协议的透传,比如你就是一个Hessian接口想对外暴露,我只需包上一层认证,直接注册于API Gateway,外部Hessian请求直接透传至内部子系统。 +某种程度上,这时候的API平台,已经不仅仅是 HTTP Rest 请求了。我们完全可以实现相同 RPC 协议的透传,比如你就是一个 Hessian 接口想对外暴露,我只需包上一层认证,直接注册于 API Gateway,外部 Hessian 请求直接透传至内部子系统。 -在这个基础上的 Rest API 平台,才是灵活的,可扩展的,易于维护的。然而有得必有失,Mock请求必然会有性能上的损耗,但是这个架构的公司,已经不在乎钱了,上10台虚机,不够加呗。 +在这个基础上的 Rest API 平台,才是灵活的,可扩展的,易于维护的。然而有得必有失,Mock 请求必然会有性能上的损耗,但是这个架构的公司,已经不在乎钱了,上 10 台虚机,不够加呗。 **2、特点** -1. C/S结构 -2. 无状态(API平台无需存储业务状态,只做认证和转发) -3. 有缓存,API会对指定URI的请求转发做缓存,保证并发性,业务系统也对同样的请求针对性缓存。 +1. C/S 结构 +2. 无状态(API 平台无需存储业务状态,只做认证和转发) +3. 有缓存,API 会对指定 URI 的请求转发做缓存,保证并发性,业务系统也对同样的请求针对性缓存。 4. 结构分层,每层间无法直接访问。 -API平台的背后,就是庞大的各个业务子系统。每个API,就相当于一个业务子系统。API平台要做的事,就非常清晰和简单。就是业务子系统注册发布API,对外部请求校验计费,模拟请求内部业务子系统,对子系统结果包装序列化为`JSON`返回。 +API 平台的背后,就是庞大的各个业务子系统。每个 API,就相当于一个业务子系统。API 平台要做的事,就非常清晰和简单。就是业务子系统注册发布 API,对外部请求校验计费,模拟请求内部业务子系统,对子系统结果包装序列化为 `JSON` 返回。 ## 2.3 交互流程 -上面是一个简单的交互,简单显示了外部系统和内部系统通过Rest API的交互过程:开发者(企业)注册,申请APP_KEY,开通API。按照开发接入,请求签名。转发至后端调用返回结果,API平台计费(预付费或者后收费),统计调用情况。 +上面是一个简单的交互,简单显示了外部系统和内部系统通过 Rest API 的交互过程:开发者(企业)注册,申请 APP_KEY,开通 API。按照开发接入,请求签名。转发至后端调用返回结果,API 平台计费(预付费或者后收费),统计调用情况。 -外部通信本质上还是`HTTP`,那么必然存在了授权问题,生产的API平台是直接暴露于公网的,如果认证授权策略出现纰漏,影响是可怕的。 +外部通信本质上还是 `HTTP`,那么必然存在了授权问题,生产的 API 平台是直接暴露于公网的,如果认证授权策略出现纰漏,影响是可怕的。 -比如,这个API是群发短信,你要是没有好的授权体系,允许人随意推送。某个人想搞你,调用发布反共信息,你整个公司都会跨。`HTTP`协议本质上没有这一块的内容,所以我们必然要在这上面考虑安全策略的内容。 +比如,这个 API 是群发短信,你要是没有好的授权体系,允许人随意推送。某个人想搞你,调用发布反共信息,你整个公司都会跨。`HTTP` 协议本质上没有这一块的内容,所以我们必然要在这上面考虑安全策略的内容。 -### 2.3.1 如何保证Rest API的安全性 +### 2.3.1 如何保证 Rest API 的安全性 -如果单纯考虑加解密,或者签名方式来保证请求合法,其实是远远不够的。事实上,一个安全的API平台往往需要多方面一起考虑,保证请求安全合法。 +如果单纯考虑加解密,或者签名方式来保证请求合法,其实是远远不够的。事实上,一个安全的 API 平台往往需要多方面一起考虑,保证请求安全合法。 **1、是不是实际客户端的请求?** -1. 设计专门的私有请求头:定义独有的Request headers,标明有此请求头的请求合法。 -2. 请求包含请求时间:定义时间,防止中间拦截篡改,只对指定超时范围内(如10秒)的请求予以响应。 -3. 请求URI是否合法:此URI是否在API平台注册?防止伪造URI攻击 -4. 请求是否包含不允许的参数定义:请求此版本的这个URI是否允许某些字段,防止注入工具。 -5. 部分竞争资源是否包含调用时版本(Etag):部分竞争资源,使用If-Match头提供。如用户资金账户查询API,可以返回此时的账户版本,修改扣款时附加版本号(类似乐观锁设计)。 +1. 设计专门的私有请求头:定义独有的 Request headers,标明有此请求头的请求合法。 +2. 请求包含请求时间:定义时间,防止中间拦截篡改,只对指定超时范围内(如 10 秒)的请求予以响应。 +3. 请求URI是否合法:此 URI 是否在 API 平台注册?防止伪造 URI 攻击 +4. 请求是否包含不允许的参数定义:请求此版本的这个 URI 是否允许某些字段,防止注入工具。 +5. 部分竞争资源是否包含调用时版本(Etag):部分竞争资源,使用 If-Match 头提供。如用户资金账户查询 API,可以返回此时的账户版本,修改扣款时附加版本号(类似乐观锁设计)。 -**2、API平台是否允许你调用(访问控制)?** +**2、API 平台是否允许你调用(访问控制)?** -访问控制,主要是授权调用部分。API都对外暴露,但是某些公共API可以直接请求,某些,需要授权请求。本质的目的,都是为了验证发起用户合法,且对用户能标识统计计费。 +访问控制,主要是授权调用部分。API 都对外暴露,但是某些公共 API 可以直接请求,某些,需要授权请求。本质的目的,都是为了验证发起用户合法,且对用户能标识统计计费。 -以HMac Auth为例,我们简单设计一个签名算法。开发者注册时获取App Key、App Secret,然后申请部分API的访问权限,发起请求时: +以 HMac Auth 为例,我们简单设计一个签名算法。开发者注册时获取 App Key、App Secret,然后申请部分 API 的访问权限,发起请求时: 1. 所有请求参数按第一个字符升序排序(先字母后数字),如第一个相同,则看第二个,依次顺延。 -2. 按请求参数名及参数值相互连接组成一个字符串。param1=value1¶m2=value2...(其中包含App Key参数) -3. 将应用密钥分别添加到以上请求参数串的头部和尾部:secret + 请求参数字符串 + secret。 +2. 按请求参数名及参数值相互连接组成一个字符串。param1=value1¶m2=value2...(其中包含 App Key 参数) +3. 将应用密钥分别添加到以上请求参数串的头部和尾部: secret + 请求参数字符串 + secret。 4. 对该字符串进行 SHA1 运算,得到一个二进制数组。 5. 将该二进制数组转换为十六进制的字符串,该字符串为此次请求的签名。 -6. 该签名值使用sign系统级参数一起和其它请求参数一起发送给API平台。 +6. 该签名值使用 sign 系统级参数一起和其它请求参数一起发送给 API 平台。 -服务端先验证`是不是实际客户端的请求`,然后按照App Key查找对应App Secret,执行签名算法,比较签名是否一致。签名一致后查看此App Key对应的用户是否有访问此API的权限,有则放行。 +服务端先验证`是不是实际客户端的请求`,然后按照 App Key 查找对应 App Secret,执行签名算法,比较签名是否一致。签名一致后查看此 App Key 对应的用户是否有访问此API的权限,有则放行。 执行成功后包装返回指定格式的结果,进行统计计费。 @@ -132,38 +132,38 @@ API平台的背后,就是庞大的各个业务子系统。每个API,就相 ### 3.1.1 系统需求 -1. 支持rest类API接口动态发布及运营,包括但不限于: +1. 支持 rest 类 API 接口动态发布及运营,包括但不限于: - 安全认证 - 会话管理 - 流量统计及限流 - 计费收费 - 熔断 -2. 支持现有子系统RPC协议的API动态发布及运营,外部请求透传。 -3. 支持json、xml响应报文,可以请求时选取所需报文格式。 -4. 支持动态直接将后端SOA服务暴露为API。 -5. 支持动态将普通Web接口暴露为API。 -6. 支持动态将MQ服务暴露为API。 -7. 支持多个服务组合编排后暴露为API。 +2. 支持现有子系统 RPC 协议的 API 动态发布及运营,外部请求透传。 +3. 支持 json、xml 响应报文,可以请求时选取所需报文格式。 +4. 支持动态直接将后端 SOA 服务暴露为 API。 +5. 支持动态将普通 Web 接口暴露为 API。 +6. 支持动态将 MQ 服务暴露为 API。 +7. 支持多个服务组合编排后暴露为 API。 ### 3.1.2 业务需求 -**1、API管理** +**1、API 管理** -所有API可后台查询管理,包括动态发布、参数映射配置、后端服务接口配置、API禁用、启用,多版本、分组、分级别等。 +所有 API 可后台查询管理,包括动态发布、参数映射配置、后端服务接口配置、API 禁用、启用,多版本、分组、分级别等。 **2、应用管理** 后台管理开放平台接入的应用(第三方应用),包括查询、禁用、启用、审核。 -**3、API鉴权&授权** +**3、API 鉴权&授权** 1. 应用申请审核通过后生成公钥,开放平台需提供支持分布式系统的密钥管理 2. 服务可设置为两个安全等级:需授权访问和无需授权访问(后者即任意客户端都可以发起调用),默认所有API都需授权访问。 3. 非正常状态(禁用、停用、黑名单等)的应用直接抛异常不允许访问——**熔断机制** - 调用次数、调用频率、并发数可运行时控制,避免某请求量过大影响其他应用的调用。 - - 可对某个应用某个API设置强制熔断,所有请求无视阀值直接抛出异常。 + - 可对某个应用某个 API 设置强制熔断,所有请求无视阀值直接抛出异常。 4. 易用性 - - 与SOA集成,SOA服务一键发布到API平台。 + - 与 SOA 集成,SOA 服务一键发布到API平台。 - 支持后台动态发布API,而不是新上一个API就需上线一次。 **4、计费统计** @@ -270,9 +270,9 @@ API 的所有服务请求域名是相同的,区别在于Request Path等。请 ## 3.3 常见框架 -1. Kong:[https://github.com/Mashape/kong](https://github.com/Mashape/kong) -2. Zuul:[https://github.com/Netflix/zuul](https://github.com/Netflix/zuul) -3. ROP:[https://github.com/itstamen/rop](https://github.com/itstamen/rop) +1. Kong: [https://github.com/Mashape/kong](https://github.com/Mashape/kong) +2. Zuul: [https://github.com/Netflix/zuul](https://github.com/Netflix/zuul) +3. ROP: [https://github.com/itstamen/rop](https://github.com/itstamen/rop) 4. Resty: [https://github.com/Dreampie/Resty](https://github.com/Dreampie/Resty) # 四、优劣