Socket
Socket
Sign inDemoInstall

@aomex/web

Package Overview
Dependencies
Maintainers
0
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 1.2.0 to 1.3.0

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [1.3.0](https://github.com/aomex/aomex/compare/v1.2.0...v1.3.0) (2024-06-28)
### Bug Fixes
* 打包时遇到类型报错 ([486f4e5](https://github.com/aomex/aomex/commit/486f4e56fa663dba757c0f3a5fb7e37210f03ab8))
### Features
* **core:** 删除中间件链条概念 ([12f42e6](https://github.com/aomex/aomex/commit/12f42e6ba15f3118b98f5ff31832121b1b2b9896))
# [1.2.0](https://github.com/aomex/aomex/compare/v1.1.0...v1.2.0) (2024-06-27)

@@ -8,0 +24,0 @@

111

dist/index.d.ts

@@ -1,2 +0,2 @@

import { I18nMessage, Next, Middleware, OpenAPI, MiddlewareChain, MixinMiddlewareToken, Validator, TransformedValidator, magistrate, MixinMiddlewareChain, I18n, ValidatorToken } from '@aomex/core';
import { I18nMessage, Next, Middleware, MixinMiddleware, OpenAPI, Validator, TransformedValidator, magistrate, I18n, ValidatorToken } from '@aomex/core';
import * as net from 'net';

@@ -11,3 +11,3 @@ import http, { IncomingMessage, ServerResponse, OutgoingHttpHeaders } from 'node:http';

import { CookieSerializeOptions } from 'cookie';
import { NonReadonly } from '@aomex/internal-tools';
import { NonReadonly, Union2Intersection } from '@aomex/internal-tools';
import { File } from 'formidable';

@@ -215,2 +215,3 @@ export { default as statuses } from 'statuses';

type WebMiddlewareToken<P extends object = object> = WebMiddleware<P> | MixinMiddleware<P>;
declare module '@aomex/core' {

@@ -250,15 +251,2 @@ interface MiddlewarePlatform {

declare module '@aomex/core' {
interface MiddlewareChainPlatform {
readonly web: WebMiddlewareChain;
}
}
type WebMiddlewareToken<P extends object = object> = WebMiddleware<P> | WebMiddlewareChain<P> | MixinMiddlewareToken<P>;
declare class WebMiddlewareChain<Props extends object = object> extends MiddlewareChain<Props> {
protected _web_chain_: 'web-chain';
mount: {
<P extends object>(middleware: WebMiddlewareToken<P> | null): WebMiddlewareChain<Props & P>;
};
}
declare module '@aomex/core' {
interface Rule {

@@ -307,27 +295,38 @@ file(): FileValidator;

interface WebAppOption {
/**
* 调试模式。默认值:`process.env.NODE_ENV !== 'production'`
*/
debug?: boolean;
/**
* 全局中间件组,挂载后该组会被打上标记。
* ```typescript
* const appChain = mdchain.web.mount(md1).mount(md2);
* const chain1 = appChain.mount(md3);
* const chain2 = chain1.mount(md4);
*
* const app = new WebApp({ box: appChain });
* ```
*/
mount?: WebMiddlewareChain | MixinMiddlewareChain;
locale?: I18n.LocaleName;
declare namespace WebApp {
interface Option<T extends WebMiddlewareToken[] | []> {
/**
* 调试模式。默认值:`process.env.NODE_ENV !== 'production'`
*/
debug?: boolean;
/**
* 全局中间件
*
* ```typescript
* const app = new WebApp({
* mount: [md1, md2]
* });
*
* declare module '@aomex/web' {
* namespace WebApp {
* type T = WebApp.Infer<typeof app>;
* interface Props extends T {}
* }
* }
* ```
*/
mount?: T;
locale?: I18n.LocaleName;
}
type Infer<T> = T extends WebApp<infer U> ? U extends any[] ? Union2Intersection<Middleware.CollectArrayType<U[number]>> : unknown : unknown;
interface Props {
}
}
declare class WebApp extends stream.EventEmitter<{
error: [err: HttpError, ctx: WebContext];
declare class WebApp<T extends WebMiddlewareToken[] | [] = any[]> extends stream.EventEmitter<{
error: [err: HttpError, ctx: WebContext & WebApp.Props];
}> {
protected readonly options: WebAppOption;
protected readonly options: WebApp.Option<T>;
protected readonly point?: string;
protected readonly middlewareList: Middleware[];
constructor(options?: WebAppOption);
protected readonly middlewareList: WebMiddlewareToken[];
constructor(options?: WebApp.Option<T>);
get debug(): boolean;

@@ -385,15 +384,2 @@ callback(): http.RequestListener<any, any>;

* 验证请求实体
*
* ```typescript
* // ctx.request.body = { id: '100', name: 'aomex' };
* chain.web
* .mount(body({
* id: rule.int().max(1000),
* name: rule.string(),
* age: rule.int().default(10)
* }))
* .mount(middleware.web((ctx, next) => {
* console.log(ctx.body); // { id: 100, name: 'aomex', age: 10 }
* }));
* ```
*/

@@ -408,14 +394,2 @@ declare const body: <T extends {

* 验证请求查询字符串
*
* ```typescript
* // ctx.request.query = { id: '100', name: 'aomex' };
* chain.web
* .mount(query({
* id: rule.int().max(1000),
* name: rule.string(),
* }))
* .mount(middleware.web((ctx, next) => {
* console.log(ctx.query); // { id: 100 }
* }));
* ```
*/

@@ -430,13 +404,2 @@ declare const query: <T extends {

* 验证请求路径参数
*
* ```typescript
* // ctx.request.params = { id: '100', name: 'aomex' };
* chain.web
* .mount(params({
* id: rule.int().max(1000),
* }))
* .mount(middleware.web((ctx, next) => {
* console.log(ctx.params); // { id: 100 }
* }));
* ```
*/

@@ -524,2 +487,2 @@ declare const params: <T extends {

export { type Body, type BodyType, FileValidator, type HttpErrorProperties, type OpenApiInjector, WebApp, type WebAppOption, WebContext, WebMiddleware, WebMiddlewareChain, type WebMiddlewareToken, WebRequest, WebResponse, WebResponseMiddleware, type WebResponseOptions, body, params, query, response };
export { type Body, type BodyType, FileValidator, type HttpErrorProperties, type OpenApiInjector, WebApp, WebContext, WebMiddleware, type WebMiddlewareToken, WebRequest, WebResponse, WebResponseMiddleware, type WebResponseOptions, body, params, query, response };

@@ -433,7 +433,3 @@ // src/i18n/locales/zh-cn.ts

// src/http/app.ts
import {
compose,
flattenMiddlewareToken,
i18n as i18n4
} from "@aomex/core";
import { compose, i18n as i18n4 } from "@aomex/core";

@@ -479,9 +475,4 @@ // src/http/context.ts

this.middlewareList = [];
if (options.locale) {
i18n4.setLocale(options.locale);
}
if (options.mount) {
this.point = options.mount["createPoint"]();
this.middlewareList = flattenMiddlewareToken(options.mount);
}
i18n4.setLocale(options.locale || "zh_CN");
this.middlewareList = options.mount || [];
}

@@ -567,8 +558,2 @@ point;

// src/override/web-middleware-chain.ts
import { MiddlewareChain } from "@aomex/core";
var WebMiddlewareChain = class extends MiddlewareChain {
};
MiddlewareChain.register("web", WebMiddlewareChain);
// src/override/file.validator.ts

@@ -803,3 +788,2 @@ import { PersistentFile } from "formidable";

WebMiddleware,
WebMiddlewareChain,
WebRequest,

@@ -806,0 +790,0 @@ WebResponse,

{
"name": "@aomex/web",
"version": "1.2.0",
"version": "1.3.0",
"description": "aomex web层应用",

@@ -28,2 +28,5 @@ "type": "module",

"license": "MIT",
"engines": {
"node": "^20.13.0 || ^22"
},
"peerDependencies": {

@@ -54,3 +57,3 @@ "@aomex/core": "^1.0.0"

"vary": "^1.1.2",
"@aomex/internal-tools": "^1.1.0"
"@aomex/internal-tools": "^1.3.0"
},

@@ -65,5 +68,5 @@ "devDependencies": {

"@types/vary": "^1.1.3",
"@aomex/core": "^1.2.0"
"@aomex/core": "^1.3.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