@aomex/web
Advanced tools
Comparing version 0.0.15 to 0.0.16
# @aomex/web | ||
## 0.0.16 | ||
### Patch Changes | ||
- [`280359e`](https://github.com/aomex/aomex/commit/280359eb90b71720304cfc212374b6dc4c90236d) Thanks [@geekact](https://github.com/geekact)! - feat(web): make file-validator immutable | ||
- [`9881653`](https://github.com/aomex/aomex/commit/988165361439738d27bc29bd0ed5a85c608db5ef) Thanks [@geekact](https://github.com/geekact)! - feat(validator)!: create namespace for each validator | ||
- [`15ecd1c`](https://github.com/aomex/aomex/commit/15ecd1c75bc21929f79980b32e63ea46e081cc6a) Thanks [@geekact](https://github.com/geekact)! - refactor(validator)!: declare magistrate namespace | ||
- Updated dependencies []: | ||
- @aomex/core@0.0.15 | ||
## 0.0.15 | ||
@@ -4,0 +17,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Chain, PureChain, PureMiddlewareToken, Next, Middleware, OpenAPI, Validator, TransformedValidator, ValidateResult, ValidatorOptions } from '@aomex/core'; | ||
import { Chain, PureChain, PureMiddlewareToken, Next, Middleware, OpenAPI, Validator, TransformedValidator, magistrate } from '@aomex/core'; | ||
import { NonReadonly } from '@aomex/utility'; | ||
@@ -272,12 +272,14 @@ import { Server, RequestListener, ServerResponse, IncomingMessage } from 'node:http'; | ||
} | ||
interface FileValidatorOptions<T> extends ValidatorOptions<T> { | ||
maxSize?: number; | ||
mimeTypes?: string[]; | ||
declare namespace FileValidator { | ||
interface Options<T> extends Validator.Options<T> { | ||
maxSize?: number; | ||
mimeTypes?: string[]; | ||
} | ||
interface FormidableFile extends File { | ||
hash: 'string'; | ||
hashAlgorithm: 'md5'; | ||
} | ||
} | ||
interface FormidableFile extends File { | ||
hash: 'string'; | ||
hashAlgorithm: 'md5'; | ||
} | ||
declare class FileValidator<T = FormidableFile> extends Validator<T> { | ||
protected config: FileValidatorOptions<T>; | ||
declare class FileValidator<T = FileValidator.FormidableFile> extends Validator<T> { | ||
protected config: FileValidator.Options<T>; | ||
optional: () => FileValidator<T | Validator.TOptional>; | ||
@@ -292,3 +294,3 @@ transform: <T1>(fn: Validator.TransformFn<T, T1>) => TransformedValidator<T1>; | ||
*/ | ||
maxSize(byte: number | string): this; | ||
maxSize(byte: number | string): FileValidator<T>; | ||
/** | ||
@@ -302,3 +304,4 @@ * ```typescript | ||
protected isEmpty(value: any): boolean; | ||
protected validateValue(file: FormidableFile, key: string, superKeys: string[]): ValidateResult<FormidableFile>; | ||
protected validateValue(file: FileValidator.FormidableFile, key: string, superKeys: string[]): magistrate.Result<FileValidator.FormidableFile>; | ||
protected copy: () => FileValidator<T>; | ||
protected toDocument(): OpenAPI.SchemaObject; | ||
@@ -439,2 +442,2 @@ } | ||
export { Body, FileValidator, FileValidatorOptions, FormidableFile, METHOD, WebApp, WebAppOption, WebBodyMiddleware, WebChain, WebContext, WebMiddleware, WebMiddlewareSkipOptions, WebMiddlewareToDocument, WebMiddlewareToken, WebParamMiddleware, WebQueryMiddleware, WebRequest, WebResponse, WebResponseMiddleware, WebResponseOptions, body, getMimeType, params, query, response, skip }; | ||
export { Body, FileValidator, METHOD, WebApp, WebAppOption, WebBodyMiddleware, WebChain, WebContext, WebMiddleware, WebMiddlewareSkipOptions, WebMiddlewareToDocument, WebMiddlewareToken, WebParamMiddleware, WebQueryMiddleware, WebRequest, WebResponse, WebResponseMiddleware, WebResponseOptions, body, getMimeType, params, query, response, skip }; |
@@ -83,7 +83,9 @@ // src/override/middleware.ts | ||
maxSize(byte) { | ||
this.config.maxSize = typeof byte === "number" ? byte : bytes(byte); | ||
return this; | ||
const validator = this.copy(); | ||
validator.config.maxSize = typeof byte === "number" ? byte : bytes(byte); | ||
return validator; | ||
} | ||
mimeTypes(mineOrExt, ...others) { | ||
this.config.mimeTypes = [ | ||
const validator = this.copy(); | ||
validator.config.mimeTypes = [ | ||
...new Set( | ||
@@ -93,3 +95,3 @@ [].concat(mineOrExt).concat(others).map(mimeTypes.contentType).filter(Boolean) | ||
]; | ||
return this; | ||
return validator; | ||
} | ||
@@ -96,0 +98,0 @@ isEmpty(value) { |
{ | ||
"name": "@aomex/web", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "", | ||
@@ -29,3 +29,3 @@ "type": "module", | ||
"peerDependencies": { | ||
"@aomex/core": "^0.0.14" | ||
"@aomex/core": "^0.0.15" | ||
}, | ||
@@ -60,3 +60,3 @@ "dependencies": { | ||
"devDependencies": { | ||
"@aomex/core": "^0.0.14", | ||
"@aomex/core": "^0.0.15", | ||
"@types/co-body": "^6.1.0", | ||
@@ -63,0 +63,0 @@ "@types/content-type": "^1.1.5", |
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
100004
1225