feat: support deploy worker with UI assets (#627)

This commit is contained in:
Dream Hunter
2025-04-12 15:37:34 +08:00
committed by GitHub
parent 32767176f0
commit 47e2cb56b4
22 changed files with 449 additions and 343 deletions

View File

@@ -11,19 +11,19 @@
"build": "wrangler deploy --dry-run --outdir dist --minify"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20250407.0",
"@cloudflare/workers-types": "^4.20250409.0",
"@eslint/js": "9.18.0",
"@simplewebauthn/types": "10.0.0",
"eslint": "9.18.0",
"globals": "^15.15.0",
"typescript-eslint": "^8.29.0",
"wrangler": "^4.7.2"
"typescript-eslint": "^8.29.1",
"wrangler": "^4.9.1"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.782.0",
"@aws-sdk/s3-request-presigner": "^3.782.0",
"@simplewebauthn/server": "10.0.1",
"hono": "^4.7.5",
"hono": "^4.7.6",
"mimetext": "^3.0.27",
"postal-mime": "^2.4.3",
"resend": "^4.2.0",

208
worker/pnpm-lock.yaml generated
View File

@@ -23,8 +23,8 @@ importers:
specifier: 10.0.1
version: 10.0.1
hono:
specifier: ^4.7.5
version: 4.7.5
specifier: ^4.7.6
version: 4.7.6
mimetext:
specifier: ^3.0.27
version: 3.0.27
@@ -42,8 +42,8 @@ importers:
version: 1.1.1
devDependencies:
'@cloudflare/workers-types':
specifier: ^4.20250407.0
version: 4.20250407.0
specifier: ^4.20250409.0
version: 4.20250409.0
'@eslint/js':
specifier: 9.18.0
version: 9.18.0
@@ -57,11 +57,11 @@ importers:
specifier: ^15.15.0
version: 15.15.0
typescript-eslint:
specifier: ^8.29.0
version: 8.29.0(eslint@9.18.0)(typescript@5.4.5)
specifier: ^8.29.1
version: 8.29.1(eslint@9.18.0)(typescript@5.4.5)
wrangler:
specifier: ^4.7.2
version: 4.7.2(@cloudflare/workers-types@4.20250407.0)
specifier: ^4.9.1
version: 4.9.1(@cloudflare/workers-types@4.20250409.0)
packages:
@@ -245,38 +245,38 @@ packages:
workerd:
optional: true
'@cloudflare/workerd-darwin-64@1.20250404.0':
resolution: {integrity: sha512-+z67wjimn7pZDJI5Ibt2TtNxreFJdFPd5dBMmQqtIfkwrlIsL4PkjHYdiffO7guFP9UygomThuKUaBOU4JA15Q==}
'@cloudflare/workerd-darwin-64@1.20250408.0':
resolution: {integrity: sha512-bxhIwBWxaNItZLXDNOKY2dCv0FHjDiDkfJFpwv4HvtvU5MKcrivZHVmmfDzLW85rqzfcDOmKbZeMPVfiKxdBZw==}
engines: {node: '>=16'}
cpu: [x64]
os: [darwin]
'@cloudflare/workerd-darwin-arm64@1.20250404.0':
resolution: {integrity: sha512-MxFuWqR5bMcc92khreSlYOJxr0OIlJxABdrWQsaogWsxI6p7Df9gV1T36pqg+ERa9fVhkkGERkalt9DJYyYicA==}
'@cloudflare/workerd-darwin-arm64@1.20250408.0':
resolution: {integrity: sha512-5XZ2Oykr8bSo7zBmERtHh18h5BZYC/6H1YFWVxEj3PtalF3+6SHsO4KZsbGvDml9Pu7sHV277jiZE5eny8Hlyw==}
engines: {node: '>=16'}
cpu: [arm64]
os: [darwin]
'@cloudflare/workerd-linux-64@1.20250404.0':
resolution: {integrity: sha512-f4rNJ45376vGB6WHmxxiZ50nmxMws337EvWthhNAZTyeoTYmJUbZjjWCaHR8clWXN8LLK1Tu1bkjsih730X41g==}
'@cloudflare/workerd-linux-64@1.20250408.0':
resolution: {integrity: sha512-WbgItXWln6G5d7GvYLWcuOzAVwafysZaWunH3UEfsm95wPuRofpYnlDD861gdWJX10IHSVgMStGESUcs7FLerQ==}
engines: {node: '>=16'}
cpu: [x64]
os: [linux]
'@cloudflare/workerd-linux-arm64@1.20250404.0':
resolution: {integrity: sha512-UW54a/vZG6W1oiA9PUSatQ0LLWrxnwAX7rN/bCFLiT6n51PP8KgpM1LzrIvQM80WjH/ufqopZJe/TSgrrSss6Q==}
'@cloudflare/workerd-linux-arm64@1.20250408.0':
resolution: {integrity: sha512-pAhEywPPvr92SLylnQfZEPgXz+9pOG9G9haAPLpEatncZwYiYd9yiR6HYWhKp2erzCoNrOqKg9IlQwU3z1IDiw==}
engines: {node: '>=16'}
cpu: [arm64]
os: [linux]
'@cloudflare/workerd-windows-64@1.20250404.0':
resolution: {integrity: sha512-AJJP8vjJ6ioBzqUxVyByv5tE74z5LZ7G5To7w7dtYjWvKZzFo39bZZwGCGryHmH4yaOylXubFv72YVH8+Y4GSQ==}
'@cloudflare/workerd-windows-64@1.20250408.0':
resolution: {integrity: sha512-nJ3RjMKGae2aF2rZ/CNeBvQPM+W5V1SUK0FYWG/uomyr7uQ2l4IayHna1ODg/OHHTEgIjwom0Mbn58iXb0WOcQ==}
engines: {node: '>=16'}
cpu: [x64]
os: [win32]
'@cloudflare/workers-types@4.20250407.0':
resolution: {integrity: sha512-M6cB247uy32VzM/P4NpRSHNNTcPgTn+s31wBV7gD14hkA07jMGBYlEcAv1LOghLNGZ5AEvYxLxQCVSvkF7HNIw==}
'@cloudflare/workers-types@4.20250409.0':
resolution: {integrity: sha512-yPxxwE5nr168huEfLNOB6904OsvIWcq0tWT23NMD6jT5SIp2ds3oOGANw7wz39r5y3jZYC2h1OnGwnZXJDDCOg==}
'@cspotcode/source-map-support@0.8.1':
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
@@ -883,51 +883,51 @@ packages:
'@types/json-schema@7.0.15':
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
'@typescript-eslint/eslint-plugin@8.29.0':
resolution: {integrity: sha512-PAIpk/U7NIS6H7TEtN45SPGLQaHNgB7wSjsQV/8+KYokAb2T/gloOA/Bee2yd4/yKVhPKe5LlaUGhAZk5zmSaQ==}
'@typescript-eslint/eslint-plugin@8.29.1':
resolution: {integrity: sha512-ba0rr4Wfvg23vERs3eB+P3lfj2E+2g3lhWcCVukUuhtcdUx5lSIFZlGFEBHKr+3zizDa/TvZTptdNHVZWAkSBg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
'@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <5.9.0'
'@typescript-eslint/parser@8.29.0':
resolution: {integrity: sha512-8C0+jlNJOwQso2GapCVWWfW/rzaq7Lbme+vGUFKE31djwNncIpgXD7Cd4weEsDdkoZDjH0lwwr3QDQFuyrMg9g==}
'@typescript-eslint/parser@8.29.1':
resolution: {integrity: sha512-zczrHVEqEaTwh12gWBIJWj8nx+ayDcCJs06yoNMY0kwjMWDM6+kppljY+BxWI06d2Ja+h4+WdufDcwMnnMEWmg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <5.9.0'
'@typescript-eslint/scope-manager@8.29.0':
resolution: {integrity: sha512-aO1PVsq7Gm+tcghabUpzEnVSFMCU4/nYIgC2GOatJcllvWfnhrgW0ZEbnTxm36QsikmCN1K/6ZgM7fok2I7xNw==}
'@typescript-eslint/scope-manager@8.29.1':
resolution: {integrity: sha512-2nggXGX5F3YrsGN08pw4XpMLO1Rgtnn4AzTegC2MDesv6q3QaTU5yU7IbS1tf1IwCR0Hv/1EFygLn9ms6LIpDA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/type-utils@8.29.0':
resolution: {integrity: sha512-ahaWQ42JAOx+NKEf5++WC/ua17q5l+j1GFrbbpVKzFL/tKVc0aYY8rVSYUpUvt2hUP1YBr7mwXzx+E/DfUWI9Q==}
'@typescript-eslint/type-utils@8.29.1':
resolution: {integrity: sha512-DkDUSDwZVCYN71xA4wzySqqcZsHKic53A4BLqmrWFFpOpNSoxX233lwGu/2135ymTCR04PoKiEEEvN1gFYg4Tw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <5.9.0'
'@typescript-eslint/types@8.29.0':
resolution: {integrity: sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==}
'@typescript-eslint/types@8.29.1':
resolution: {integrity: sha512-VT7T1PuJF1hpYC3AGm2rCgJBjHL3nc+A/bhOp9sGMKfi5v0WufsX/sHCFBfNTx2F+zA6qBc/PD0/kLRLjdt8mQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/typescript-estree@8.29.0':
resolution: {integrity: sha512-yOfen3jE9ISZR/hHpU/bmNvTtBW1NjRbkSFdZOksL1N+ybPEE7UVGMwqvS6CP022Rp00Sb0tdiIkhSCe6NI8ow==}
'@typescript-eslint/typescript-estree@8.29.1':
resolution: {integrity: sha512-l1enRoSaUkQxOQnbi0KPUtqeZkSiFlqrx9/3ns2rEDhGKfTa+88RmXqedC1zmVTOWrLc2e6DEJrTA51C9iLH5g==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <5.9.0'
'@typescript-eslint/utils@8.29.0':
resolution: {integrity: sha512-gX/A0Mz9Bskm8avSWFcK0gP7cZpbY4AIo6B0hWYFCaIsz750oaiWR4Jr2CI+PQhfW1CpcQr9OlfPS+kMFegjXA==}
'@typescript-eslint/utils@8.29.1':
resolution: {integrity: sha512-QAkFEbytSaB8wnmB+DflhUPz6CLbFWE2SnSCrRMEa+KnXIzDYbpsn++1HGvnfAsUY44doDXmvRkO5shlM/3UfA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <5.9.0'
'@typescript-eslint/visitor-keys@8.29.0':
resolution: {integrity: sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==}
'@typescript-eslint/visitor-keys@8.29.1':
resolution: {integrity: sha512-RGLh5CRaUEf02viP5c1Vh1cMGffQscyHe7HPAzGpfmfflFg1wUz2rYxd+OZqwpeypYvZ8UxSxuIpF++fmOzEcg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
abort-controller@3.0.0:
@@ -1218,8 +1218,8 @@ packages:
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
engines: {node: '>=8'}
hono@4.7.5:
resolution: {integrity: sha512-fDOK5W2C1vZACsgLONigdZTRZxuBqFtcKh7bUQ5cVSbwI2RWjloJDcgFOVzbQrlI6pCmhlTsVYZ7zpLj4m4qMQ==}
hono@4.7.6:
resolution: {integrity: sha512-564rVzELU+9BRqqx5k8sT2NFwGD3I3Vifdb6P7CmM6FiarOSY+fDC+6B+k9wcCb86ReoayteZP2ki0cRLN1jbw==}
engines: {node: '>=16.9.0'}
html-to-text@9.0.5:
@@ -1323,8 +1323,8 @@ packages:
mimetext@3.0.27:
resolution: {integrity: sha512-mUhWAsZD1N/K6dbN4+a5Yq78OPnYQw1ubOSMasBntsLQ2S7KVNlvDEA8dwpr4a7PszWMzeslKahAprtwYMgaBA==}
miniflare@4.20250404.0:
resolution: {integrity: sha512-OeNnXrOdgSoN5iDA+u1Ue3etOyPY89BJFFizMgGEPJvGTYL+kZhKqeBKeZiZIS7xjjlrfXNqleYGnCyomQ1pDQ==}
miniflare@4.20250408.0:
resolution: {integrity: sha512-h1FAK1l/RzZyhGAeLKD+XawWBWowY8tjOcj0Yz8RmCpZ5xBfl255O5eGw4Xk1rcpgxyEB0qiaL2CmV9HAyMfhw==}
engines: {node: '>=18.0.0'}
hasBin: true
@@ -1544,8 +1544,8 @@ packages:
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
engines: {node: '>= 0.8.0'}
typescript-eslint@8.29.0:
resolution: {integrity: sha512-ep9rVd9B4kQsZ7ZnWCVxUE/xDLUUUsRzE0poAeNu+4CkFErLfuvPt/qtm2EpnSyfvsR0S6QzDFSrPCFBwf64fg==}
typescript-eslint@8.29.1:
resolution: {integrity: sha512-f8cDkvndhbQMPcysk6CUSGBWV+g1utqdn71P5YKwMumVMOG/5k7cHq0KyG4O52nB0oKS4aN2Tp5+wB4APJGC+w==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
@@ -1556,8 +1556,8 @@ packages:
engines: {node: '>=14.17'}
hasBin: true
ufo@1.5.4:
resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==}
ufo@1.6.1:
resolution: {integrity: sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==}
undici@5.29.0:
resolution: {integrity: sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==}
@@ -1591,17 +1591,17 @@ packages:
worker-mailer@1.1.1:
resolution: {integrity: sha512-UPPd48aBMVuAE2j9ha7wDEhBakM23zKBk8wd9lLUhChExPeq8B8cO6C1ur4hMOypmJO7mZ+xTZff1KoCKprvGA==}
workerd@1.20250404.0:
resolution: {integrity: sha512-dvXsRdy49/vd4nPENpTDFjbPvR3XdPa8lJrxcnDKL1XtoioYXflq3ys8ljuu+X71ojqAAjnQj62AzrmmKM095g==}
workerd@1.20250408.0:
resolution: {integrity: sha512-bBUX+UsvpzAqiWFNeZrlZmDGddiGZdBBbftZJz2wE6iUg/cIAJeVQYTtS/3ahaicguoLBz4nJiDo8luqM9fx1A==}
engines: {node: '>=16'}
hasBin: true
wrangler@4.7.2:
resolution: {integrity: sha512-fK9h7PL8wrrdSLCFXVDotoSHOebRmdNdB4VRkUDWOIyiP0Dx54TBfXTt3bXB98EYx7VT+vj6CNVnEC8gSCxt0w==}
wrangler@4.9.1:
resolution: {integrity: sha512-wBV0OKFp+4Ii4bFIIBRm1JJi1od5KGhzsUjWw+2jtlX/H0n2TkdskMDQtrOdV9ybFKj2h+v93VxhAEBePghAkQ==}
engines: {node: '>=18.0.0'}
hasBin: true
peerDependencies:
'@cloudflare/workers-types': ^4.20250404.0
'@cloudflare/workers-types': ^4.20250408.0
peerDependenciesMeta:
'@cloudflare/workers-types':
optional: true
@@ -2119,28 +2119,28 @@ snapshots:
dependencies:
mime: 3.0.0
'@cloudflare/unenv-preset@2.3.1(unenv@2.0.0-rc.15)(workerd@1.20250404.0)':
'@cloudflare/unenv-preset@2.3.1(unenv@2.0.0-rc.15)(workerd@1.20250408.0)':
dependencies:
unenv: 2.0.0-rc.15
optionalDependencies:
workerd: 1.20250404.0
workerd: 1.20250408.0
'@cloudflare/workerd-darwin-64@1.20250404.0':
'@cloudflare/workerd-darwin-64@1.20250408.0':
optional: true
'@cloudflare/workerd-darwin-arm64@1.20250404.0':
'@cloudflare/workerd-darwin-arm64@1.20250408.0':
optional: true
'@cloudflare/workerd-linux-64@1.20250404.0':
'@cloudflare/workerd-linux-64@1.20250408.0':
optional: true
'@cloudflare/workerd-linux-arm64@1.20250404.0':
'@cloudflare/workerd-linux-arm64@1.20250408.0':
optional: true
'@cloudflare/workerd-windows-64@1.20250404.0':
'@cloudflare/workerd-windows-64@1.20250408.0':
optional: true
'@cloudflare/workers-types@4.20250407.0': {}
'@cloudflare/workers-types@4.20250409.0': {}
'@cspotcode/source-map-support@0.8.1':
dependencies:
@@ -2786,14 +2786,14 @@ snapshots:
'@types/json-schema@7.0.15': {}
'@typescript-eslint/eslint-plugin@8.29.0(@typescript-eslint/parser@8.29.0(eslint@9.18.0)(typescript@5.4.5))(eslint@9.18.0)(typescript@5.4.5)':
'@typescript-eslint/eslint-plugin@8.29.1(@typescript-eslint/parser@8.29.1(eslint@9.18.0)(typescript@5.4.5))(eslint@9.18.0)(typescript@5.4.5)':
dependencies:
'@eslint-community/regexpp': 4.12.1
'@typescript-eslint/parser': 8.29.0(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/scope-manager': 8.29.0
'@typescript-eslint/type-utils': 8.29.0(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/utils': 8.29.0(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/visitor-keys': 8.29.0
'@typescript-eslint/parser': 8.29.1(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/scope-manager': 8.29.1
'@typescript-eslint/type-utils': 8.29.1(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/utils': 8.29.1(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/visitor-keys': 8.29.1
eslint: 9.18.0
graphemer: 1.4.0
ignore: 5.3.2
@@ -2803,27 +2803,27 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/parser@8.29.0(eslint@9.18.0)(typescript@5.4.5)':
'@typescript-eslint/parser@8.29.1(eslint@9.18.0)(typescript@5.4.5)':
dependencies:
'@typescript-eslint/scope-manager': 8.29.0
'@typescript-eslint/types': 8.29.0
'@typescript-eslint/typescript-estree': 8.29.0(typescript@5.4.5)
'@typescript-eslint/visitor-keys': 8.29.0
'@typescript-eslint/scope-manager': 8.29.1
'@typescript-eslint/types': 8.29.1
'@typescript-eslint/typescript-estree': 8.29.1(typescript@5.4.5)
'@typescript-eslint/visitor-keys': 8.29.1
debug: 4.4.0
eslint: 9.18.0
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
'@typescript-eslint/scope-manager@8.29.0':
'@typescript-eslint/scope-manager@8.29.1':
dependencies:
'@typescript-eslint/types': 8.29.0
'@typescript-eslint/visitor-keys': 8.29.0
'@typescript-eslint/types': 8.29.1
'@typescript-eslint/visitor-keys': 8.29.1
'@typescript-eslint/type-utils@8.29.0(eslint@9.18.0)(typescript@5.4.5)':
'@typescript-eslint/type-utils@8.29.1(eslint@9.18.0)(typescript@5.4.5)':
dependencies:
'@typescript-eslint/typescript-estree': 8.29.0(typescript@5.4.5)
'@typescript-eslint/utils': 8.29.0(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/typescript-estree': 8.29.1(typescript@5.4.5)
'@typescript-eslint/utils': 8.29.1(eslint@9.18.0)(typescript@5.4.5)
debug: 4.4.0
eslint: 9.18.0
ts-api-utils: 2.1.0(typescript@5.4.5)
@@ -2831,12 +2831,12 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/types@8.29.0': {}
'@typescript-eslint/types@8.29.1': {}
'@typescript-eslint/typescript-estree@8.29.0(typescript@5.4.5)':
'@typescript-eslint/typescript-estree@8.29.1(typescript@5.4.5)':
dependencies:
'@typescript-eslint/types': 8.29.0
'@typescript-eslint/visitor-keys': 8.29.0
'@typescript-eslint/types': 8.29.1
'@typescript-eslint/visitor-keys': 8.29.1
debug: 4.4.0
fast-glob: 3.3.3
is-glob: 4.0.3
@@ -2847,20 +2847,20 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/utils@8.29.0(eslint@9.18.0)(typescript@5.4.5)':
'@typescript-eslint/utils@8.29.1(eslint@9.18.0)(typescript@5.4.5)':
dependencies:
'@eslint-community/eslint-utils': 4.5.1(eslint@9.18.0)
'@typescript-eslint/scope-manager': 8.29.0
'@typescript-eslint/types': 8.29.0
'@typescript-eslint/typescript-estree': 8.29.0(typescript@5.4.5)
'@typescript-eslint/scope-manager': 8.29.1
'@typescript-eslint/types': 8.29.1
'@typescript-eslint/typescript-estree': 8.29.1(typescript@5.4.5)
eslint: 9.18.0
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
'@typescript-eslint/visitor-keys@8.29.0':
'@typescript-eslint/visitor-keys@8.29.1':
dependencies:
'@typescript-eslint/types': 8.29.0
'@typescript-eslint/types': 8.29.1
eslint-visitor-keys: 4.2.0
abort-controller@3.0.0:
@@ -3178,7 +3178,7 @@ snapshots:
has-flag@4.0.0: {}
hono@4.7.5: {}
hono@4.7.6: {}
html-to-text@9.0.5:
dependencies:
@@ -3274,7 +3274,7 @@ snapshots:
js-base64: 3.7.7
mime-types: 2.1.35
miniflare@4.20250404.0:
miniflare@4.20250408.0:
dependencies:
'@cspotcode/source-map-support': 0.8.1
acorn: 8.14.0
@@ -3283,7 +3283,7 @@ snapshots:
glob-to-regexp: 0.4.1
stoppable: 1.1.0
undici: 5.29.0
workerd: 1.20250404.0
workerd: 1.20250408.0
ws: 8.18.0
youch: 3.3.4
zod: 3.22.3
@@ -3503,11 +3503,11 @@ snapshots:
dependencies:
prelude-ls: 1.2.1
typescript-eslint@8.29.0(eslint@9.18.0)(typescript@5.4.5):
typescript-eslint@8.29.1(eslint@9.18.0)(typescript@5.4.5):
dependencies:
'@typescript-eslint/eslint-plugin': 8.29.0(@typescript-eslint/parser@8.29.0(eslint@9.18.0)(typescript@5.4.5))(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/parser': 8.29.0(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/utils': 8.29.0(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/eslint-plugin': 8.29.1(@typescript-eslint/parser@8.29.1(eslint@9.18.0)(typescript@5.4.5))(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/parser': 8.29.1(eslint@9.18.0)(typescript@5.4.5)
'@typescript-eslint/utils': 8.29.1(eslint@9.18.0)(typescript@5.4.5)
eslint: 9.18.0
typescript: 5.4.5
transitivePeerDependencies:
@@ -3515,7 +3515,7 @@ snapshots:
typescript@5.4.5: {}
ufo@1.5.4: {}
ufo@1.6.1: {}
undici@5.29.0:
dependencies:
@@ -3527,7 +3527,7 @@ snapshots:
exsolve: 1.0.4
ohash: 2.0.11
pathe: 2.0.3
ufo: 1.5.4
ufo: 1.6.1
uri-js@4.4.1:
dependencies:
@@ -3550,26 +3550,26 @@ snapshots:
worker-mailer@1.1.1: {}
workerd@1.20250404.0:
workerd@1.20250408.0:
optionalDependencies:
'@cloudflare/workerd-darwin-64': 1.20250404.0
'@cloudflare/workerd-darwin-arm64': 1.20250404.0
'@cloudflare/workerd-linux-64': 1.20250404.0
'@cloudflare/workerd-linux-arm64': 1.20250404.0
'@cloudflare/workerd-windows-64': 1.20250404.0
'@cloudflare/workerd-darwin-64': 1.20250408.0
'@cloudflare/workerd-darwin-arm64': 1.20250408.0
'@cloudflare/workerd-linux-64': 1.20250408.0
'@cloudflare/workerd-linux-arm64': 1.20250408.0
'@cloudflare/workerd-windows-64': 1.20250408.0
wrangler@4.7.2(@cloudflare/workers-types@4.20250407.0):
wrangler@4.9.1(@cloudflare/workers-types@4.20250409.0):
dependencies:
'@cloudflare/kv-asset-handler': 0.4.0
'@cloudflare/unenv-preset': 2.3.1(unenv@2.0.0-rc.15)(workerd@1.20250404.0)
'@cloudflare/unenv-preset': 2.3.1(unenv@2.0.0-rc.15)(workerd@1.20250408.0)
blake3-wasm: 2.1.5
esbuild: 0.24.2
miniflare: 4.20250404.0
miniflare: 4.20250408.0
path-to-regexp: 6.3.0
unenv: 2.0.0-rc.15
workerd: 1.20250404.0
workerd: 1.20250408.0
optionalDependencies:
'@cloudflare/workers-types': 4.20250407.0
'@cloudflare/workers-types': 4.20250409.0
fsevents: 2.3.3
sharp: 0.33.5
transitivePeerDependencies:

View File

@@ -10,6 +10,7 @@ export type Bindings = {
KV: KVNamespace
RATE_LIMITER: any
SEND_MAIL: any
ASSETS: Fetcher
// config
DEFAULT_LANG: string | undefined

View File

@@ -16,6 +16,15 @@ import { scheduled } from './scheduled';
import { getAdminPasswords, getPasswords, getBooleanValue, getStringArray } from './utils';
import { HonoCustomType, UserPayload } from './types';
const API_PATHS = [
"/api/",
"/open_api/",
"/user_api/",
"/admin/",
"/telegram/",
"/external/",
];
const app = new Hono<HonoCustomType>()
//cors
app.use('/*', cors());
@@ -24,8 +33,18 @@ app.onError((err, c) => {
console.error(err)
return c.text(`${err.name} ${err.message}`, 500)
})
// rate limit
// global middlewares
app.use('/*', async (c, next) => {
// check if the request is for static files
if (c.env.ASSETS && !API_PATHS.some(path => c.req.path.startsWith(path))) {
const url = new URL(c.req.raw.url);
if (!url.pathname.includes('.')) {
url.pathname = ""
}
return c.env.ASSETS.fetch(url);
}
// save language in context
const lang = c.req.raw.headers.get("x-lang");
if (lang) { c.set("lang", lang); }

View File

@@ -1,12 +1,18 @@
name = "cloudflare_temp_email"
main = "src/worker.ts"
compatibility_date = "2024-09-23"
compatibility_date = "2025-04-01"
compatibility_flags = [ "nodejs_compat" ]
# if you want use custom_domain, you need to add routes
# routes = [
# { pattern = "temp-email-api.xxxxx.xyz", custom_domain = true },
# ]
# if you want deploy worker with frontend assets, you need to add assets
# [assets]
# directory = "../frontend/dist/"
# binding = "ASSETS"
# run_worker_first = true
# enable cron if you want set auto clean up
# [triggers]
# crons = [ "0 0 * * *" ]