@aomex/web
Advanced tools
Comparing version 1.5.1 to 1.6.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [1.6.0](https://github.com/aomex/aomex/compare/v1.5.1...v1.6.0) (2024-07-05) | ||
### Features | ||
* **web:** response.download修改签名 ([849b150](https://github.com/aomex/aomex/commit/849b1509f8eee7687189339ee4b77588f6451890)) | ||
## [1.5.1](https://github.com/aomex/aomex/compare/v1.5.0...v1.5.1) (2024-07-04) | ||
@@ -8,0 +19,0 @@ |
@@ -9,3 +9,2 @@ import { I18nMessage, Next, Middleware, MixinMiddleware, OpenAPI, Validator, TransformedValidator, magistrate, I18n, ValidatorToken } from '@aomex/core'; | ||
export { HttpError, default as createHttpError } from 'http-errors'; | ||
import contentDisposition from 'content-disposition'; | ||
import { CookieSerializeOptions } from 'cookie'; | ||
@@ -137,3 +136,12 @@ import { NonReadonly, Union2Intersection } from '@aomex/internal-tools'; | ||
set body(val: Body); | ||
download(filePath: string, options?: contentDisposition.Options): void; | ||
/** | ||
* 下载文件 | ||
* | ||
* @param filePath 路径 | ||
* @param type 附件类型。默认值:`attachment` | ||
* | ||
* @link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Disposition | ||
* | ||
*/ | ||
download(filePath: string, type?: 'attachment' | 'inline'): void; | ||
getHeader: { | ||
@@ -140,0 +148,0 @@ (name: UpperStringHeaderKeys): string | undefined; |
@@ -38,3 +38,3 @@ // src/i18n/locales/zh-cn.ts | ||
import { IncomingMessage } from "node:http"; | ||
import qs from "qs"; | ||
import qs from "node:querystring"; | ||
import typeIs from "type-is"; | ||
@@ -169,3 +169,3 @@ import requestIP from "request-ip"; | ||
// src/http/response.ts | ||
import stream from "stream"; | ||
import stream from "node:stream"; | ||
import destroy from "destroy"; | ||
@@ -252,5 +252,14 @@ import createHttpError, { isHttpError } from "http-errors"; | ||
} | ||
download(filePath, options = {}) { | ||
/** | ||
* 下载文件 | ||
* | ||
* @param filePath 路径 | ||
* @param type 附件类型。默认值:`attachment` | ||
* | ||
* @link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Disposition | ||
* | ||
*/ | ||
download(filePath, type = "attachment") { | ||
this.contentType = extname(filePath); | ||
this.setHeader("content-disposition", contentDisposition(filePath, options)); | ||
this.setHeader("content-disposition", contentDisposition(filePath, { type })); | ||
this.body = createReadStream(filePath); | ||
@@ -257,0 +266,0 @@ } |
{ | ||
"name": "@aomex/web", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "aomex web层应用", | ||
@@ -36,7 +36,5 @@ "type": "module", | ||
"@types/accepts": "^1.3.7", | ||
"@types/content-disposition": "^0.5.8", | ||
"@types/cookie": "^0.6.0", | ||
"@types/formidable": "^3.4.5", | ||
"@types/http-errors": "^2.0.4", | ||
"@types/qs": "^6.9.14", | ||
"@types/statuses": "^2.0.5", | ||
@@ -52,3 +50,2 @@ "accepts": "^1.3.8", | ||
"mime-types": "^2.1.35", | ||
"qs": "^6.12.0", | ||
"request-ip": "^3.3.0", | ||
@@ -58,6 +55,7 @@ "statuses": "^2.0.1", | ||
"vary": "^1.1.2", | ||
"@aomex/internal-tools": "^1.5.1" | ||
"@aomex/internal-tools": "^1.6.0" | ||
}, | ||
"devDependencies": { | ||
"@types/co-body": "^6.1.3", | ||
"@types/content-disposition": "^0.5.8", | ||
"@types/destroy": "^1.0.3", | ||
@@ -69,5 +67,5 @@ "@types/fresh": "^0.5.2", | ||
"@types/vary": "^1.1.3", | ||
"@aomex/core": "^1.5.1" | ||
"@aomex/core": "^1.6.0" | ||
}, | ||
"scripts": {} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103269
20
1288
9
- Removed@types/content-disposition@^0.5.8
- Removed@types/qs@^6.9.14
- Removedqs@^6.12.0
- Removed@types/content-disposition@0.5.8(transitive)
- Removed@types/qs@6.9.15(transitive)
Updated@aomex/internal-tools@^1.6.0