Socket
Socket
Sign inDemoInstall

@aomex/web

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aomex/web - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

19

CHANGELOG.md
# @aomex/web
## 0.0.3
### Patch Changes
- [`4735157`](https://github.com/aomex/aomex/commit/4735157c52d0abecc41d6c7f416280ebfd6ee696) Thanks [@geekact](https://github.com/geekact)! - 响应未设置 statusCode
- [`d6ac7b5`](https://github.com/aomex/aomex/commit/d6ac7b5403334b51fa15dbe82dd6b5b6d048f661) Thanks [@geekact](https://github.com/geekact)! - response 增加 vary 方法
- [`9254754`](https://github.com/aomex/aomex/commit/9254754d234fc0062eb5d600284ee8453825306c) Thanks [@geekact](https://github.com/geekact)! - response 增加 varyAppend 方法
- [`6056f55`](https://github.com/aomex/aomex/commit/6056f556577865220d6b5be2a4eafad9e4dbf8d4) Thanks [@geekact](https://github.com/geekact)! - request 增加 ip 属性
- [`1c67399`](https://github.com/aomex/aomex/commit/1c673992c4b313c2accb4cbc1fc66537a9886c29) Thanks [@geekact](https://github.com/geekact)! - 导出 HttpError 类型
- [`352642a`](https://github.com/aomex/aomex/commit/352642abf2ccb3fe97e2d83a691d8428ccfc9758) Thanks [@geekact](https://github.com/geekact)! - request 增加 fresh 属性
- Updated dependencies [[`d1ce4e2`](https://github.com/aomex/aomex/commit/d1ce4e2276f93c44e67ea06666d048917fa94e53)]:
- @aomex/core@0.0.2
## 0.0.2

@@ -4,0 +23,0 @@

@@ -6,2 +6,3 @@ import { Chain, PureChain, PureMiddlewareToken, Next, Middleware, OpenAPI, Validator, TValidatorOptional, ValidatorTransformFn, TransformedValidator, ValidateResult, ValidatorOptions, GetValidatorType } from '@aomex/core';

import { HttpError } from 'http-errors';
export { HttpError } from 'http-errors';
import { IParseOptions } from 'qs';

@@ -49,2 +50,4 @@ import { Stream } from 'node:stream';

get accept(): Accepts;
get ip(): string;
get fresh(): boolean;
}

@@ -65,3 +68,6 @@ declare module 'node:http' {

protected _explicitBody: boolean;
protected _explicitStatus: boolean;
constructor(req: Request);
/** @ts-expect-error */
set statusCode(code: number);
readonly setHeader: {

@@ -107,2 +113,6 @@ <T extends WebResponse>(name: StringHeaderKeys, value: number | string): T;

findContentType(type: string, ...types: string[]): string | null;
vary(field: HeaderKeys | HeaderKeys[]): void;
vary(field: string | string[]): void;
varyAppend(header: HeaderKeys, field: string | string[]): string;
varyAppend(header: string, field: string | string[]): string;
}

@@ -109,0 +119,0 @@

48

dist/index.js

@@ -138,2 +138,4 @@ // src/override/middleware.ts

import contentType from "content-type";
import requestIP from "request-ip";
import fresh from "fresh";
var WebRequest = class extends IncomingMessage {

@@ -198,2 +200,16 @@ app;

}
get ip() {
return requestIP.getClientIp(this) || "";
}
get fresh() {
const method = this.method;
const status = this.res.statusCode;
if (method !== "GET" && method !== "HEAD")
return false;
if (status < 200)
return false;
if (status > 299 && status !== 304)
return false;
return fresh(this.headers, this.res.getHeaders());
}
};

@@ -230,2 +246,3 @@

import typeIs2 from "type-is";
import vary from "vary";
var WebResponse = class extends ServerResponse {

@@ -236,5 +253,12 @@ app;

_explicitBody = false;
_explicitStatus = false;
constructor(req) {
super(req);
super.statusCode = 404;
}
/** @ts-expect-error */
set statusCode(code) {
this._explicitStatus = true;
super.statusCode = code;
}
/**

@@ -310,2 +334,5 @@ * 批量设置头部数据

this._explicitBody = true;
if (!this._explicitStatus) {
this.statusCode = 200;
}
}

@@ -324,2 +351,5 @@ flush() {

};
if (!this._explicitStatus) {
this.statusCode = 200;
}
if (statuses.empty[this.statusCode]) {

@@ -395,2 +425,8 @@ this.removeHeader("content-type");

}
vary(field) {
return vary(this, field);
}
varyAppend(header, field) {
return vary.append(header, field);
}
};

@@ -405,5 +441,3 @@

this.globalChainPoint = Chain2.createPoint(options.globalChain);
this.middlewareList = Chain2.flatten(
options.globalChain
);
this.middlewareList = [options.globalChain];
} else {

@@ -431,5 +465,3 @@ this.middlewareList = [];

return (req, res) => {
res.statusCode = 404;
const ctx = new WebContext(this, req, res);
return fn(ctx).then(res.flush.bind(res)).catch(res.onError.bind(res));
return fn(new WebContext(this, req, res)).then(res.flush.bind(res)).catch(res.onError.bind(res));
};

@@ -557,4 +589,8 @@ }

var params = (fields) => new WebParamMiddleware(fields);
// src/index.ts
import { HttpError } from "http-errors";
export {
FileValidator,
HttpError,
WebApp,

@@ -561,0 +597,0 @@ WebBodyMiddleware,

17

package.json
{
"name": "@aomex/web",
"version": "0.0.2",
"version": "0.0.3",
"description": "",

@@ -25,6 +25,7 @@ "type": "module",

"keywords": [],
"author": "geekact",
"repository": "git@github.com:aomex/aomex.git",
"homepage": "https://aomex.js.org",
"license": "MIT",
"peerDependencies": {
"@aomex/core": "^0.0.1"
"@aomex/core": "^0.0.2"
},

@@ -43,2 +44,3 @@ "dependencies": {

"formidable": "^3.2.5",
"fresh": "^0.5.2",
"http-errors": "^2.0.0",

@@ -49,6 +51,9 @@ "lru-cache": "^7.14.1",

"qs": "^6.11.0",
"request-ip": "^3.3.0",
"statuses": "^2.0.1",
"type-is": "^1.6.18"
"type-is": "^1.6.18",
"vary": "^1.1.2"
},
"devDependencies": {
"@aomex/core": "^0.0.2",
"@types/accepts": "^1.3.5",

@@ -61,10 +66,12 @@ "@types/co-body": "^6.1.0",

"@types/formidable": "^2.0.5",
"@types/fresh": "^0.5.0",
"@types/http-errors": "^2.0.1",
"@types/mime-types": "^2.1.1",
"@types/parseurl": "^1.3.1",
"@types/request-ip": "^0.0.37",
"@types/statuses": "^2.0.1",
"@types/type-is": "^1.6.3",
"@aomex/core": "^0.0.1"
"@types/vary": "^1.1.0"
},
"scripts": {}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc