diff --git a/functions/api/[[route]].ts b/functions/api/[[route]].ts index fb080c7..899eb85 100644 --- a/functions/api/[[route]].ts +++ b/functions/api/[[route]].ts @@ -4,6 +4,9 @@ import { Bot, InputFile, InputMediaBuilder } from 'grammy' import { Hono } from 'hono' import { env } from 'hono/adapter' import { handle } from 'hono/cloudflare-pages' +import { customAlphabet } from 'nanoid' + +const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', 8) const IP_HEADER = 'CF-Connecting-IP' @@ -69,7 +72,7 @@ app.post('/api/v1/suggestion', async (c) => { return c.json(newErrorFormat400(), 400) } - const msgs = [`意见箱收到新消息\n`] + const msgs = [`意见箱收到新消息 #TN-${nanoid()}\n`] msgs.push(`${replaceHtmlTag(textContent)}\n`) contactContent && msgs.push( diff --git a/functions/package.json b/functions/package.json index a261d15..a82eaf3 100644 --- a/functions/package.json +++ b/functions/package.json @@ -8,7 +8,7 @@ "dependencies": { "grammy": "^1.21.1", "hono": "^4.0.8", - "nano-id": "^1.1.0" + "nanoid": "^5.1.0" }, "devDependencies": { "@cloudflare/workers-types": "^4.20240208.0" diff --git a/functions/tsconfig.json b/functions/tsconfig.json index 4c14493..d2ca13c 100644 --- a/functions/tsconfig.json +++ b/functions/tsconfig.json @@ -1,21 +1,21 @@ { "compilerOptions": { "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, + "jsx": "preserve", "lib": [ "ESNext" ], + "module": "ESNext", + "moduleResolution": "Bundler", "types": [ "@cloudflare/workers-types" ], - "jsx": "preserve", + "strict": true, "strictNullChecks": true, "noImplicitAny": true, "noUnusedLocals": true, "noUnusedParameters": true, - "skipLibCheck": true, - "skipDefaultLibCheck": true - }, + "skipDefaultLibCheck": true, + "skipLibCheck": true + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ffa549c..7805a28 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -66,9 +66,9 @@ importers: hono: specifier: ^4.0.8 version: 4.6.13 - nano-id: - specifier: ^1.1.0 - version: 1.1.0 + nanoid: + specifier: ^5.1.0 + version: 5.1.0 devDependencies: '@cloudflare/workers-types': specifier: ^4.20240208.0 @@ -2639,14 +2639,16 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - nano-id@1.1.0: - resolution: {integrity: sha512-vQB87xWh4CCBZq2d7/wF46uiwZOx+n6ShQ4QBuiejQhBSijkTeK6Ugv1EhgjVAg8fwIu9wtWk3GhCN4ViD0TJQ==} - nanoid@3.3.8: resolution: {integrity: sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + nanoid@5.1.0: + resolution: {integrity: sha512-zDAl/llz8Ue/EblwSYwdxGBYfj46IM1dhjVi8dyp9LQffoIGxJEAHj2oeZ4uNcgycSRcQ83CnfcZqEJzVDLcDw==} + engines: {node: ^18 || >=20} + hasBin: true + natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} @@ -6380,10 +6382,10 @@ snapshots: ms@2.1.3: {} - nano-id@1.1.0: {} - nanoid@3.3.8: {} + nanoid@5.1.0: {} + natural-compare@1.4.0: {} natural-orderby@5.0.0: {}