@jayfong/x-server 1.24.2 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/lib/_cjs/core/server.js +6 -2
- package/lib/_cjs/index.js +8 -0
- package/lib/_cjs/plugins/form_body_parser.js +24 -0
- package/lib/core/server.js +6 -2
- package/lib/core/types.d.ts +9 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/plugins/form_body_parser.d.ts +13 -0
- package/lib/plugins/form_body_parser.js +15 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.25.0](https://github.com/jfWorks/x-server/compare/v1.24.2...v1.25.0) (2022-05-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add FormBodyParserPlugin ([b51392c](https://github.com/jfWorks/x-server/commit/b51392c5dce6480f9f5250192f676421c6a1cad2))
|
|
11
|
+
* ctx add req res ([ccd1ea0](https://github.com/jfWorks/x-server/commit/ccd1ea08f9d10e0b29ff235b1b6572b180798d8d))
|
|
12
|
+
|
|
5
13
|
### [1.24.2](https://github.com/jfWorks/x-server/compare/v1.24.1...v1.24.2) (2022-05-02)
|
|
6
14
|
|
|
7
15
|
|
package/lib/_cjs/core/server.js
CHANGED
|
@@ -104,7 +104,9 @@ class Server {
|
|
|
104
104
|
headers: req.headers,
|
|
105
105
|
setHeader: (k, v) => res.header(k, v),
|
|
106
106
|
redirect: undefined,
|
|
107
|
-
ws: req
|
|
107
|
+
ws: req,
|
|
108
|
+
req: req,
|
|
109
|
+
res: res
|
|
108
110
|
});
|
|
109
111
|
return;
|
|
110
112
|
}
|
|
@@ -132,7 +134,9 @@ class Server {
|
|
|
132
134
|
headers: req.headers,
|
|
133
135
|
setHeader: (k, v) => res.header(k, v),
|
|
134
136
|
redirect: url => res.redirect(url),
|
|
135
|
-
ws: undefined
|
|
137
|
+
ws: undefined,
|
|
138
|
+
req: req,
|
|
139
|
+
res: res
|
|
136
140
|
});
|
|
137
141
|
return data;
|
|
138
142
|
}
|
package/lib/_cjs/index.js
CHANGED
|
@@ -114,6 +114,14 @@ Object.keys(_file_parser).forEach(function (key) {
|
|
|
114
114
|
exports[key] = _file_parser[key];
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
+
var _form_body_parser = require("./plugins/form_body_parser");
|
|
118
|
+
|
|
119
|
+
Object.keys(_form_body_parser).forEach(function (key) {
|
|
120
|
+
if (key === "default" || key === "__esModule") return;
|
|
121
|
+
if (key in exports && exports[key] === _form_body_parser[key]) return;
|
|
122
|
+
exports[key] = _form_body_parser[key];
|
|
123
|
+
});
|
|
124
|
+
|
|
117
125
|
var _ws_parser = require("./plugins/ws_parser");
|
|
118
126
|
|
|
119
127
|
Object.keys(_ws_parser).forEach(function (key) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.FormBodyParserPlugin = void 0;
|
|
7
|
+
|
|
8
|
+
var _formbody = _interopRequireDefault(require("@fastify/formbody"));
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* POST application/x-www-form-urlencoded 解析器插件
|
|
12
|
+
*/
|
|
13
|
+
class FormBodyParserPlugin {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
register(fastify) {
|
|
19
|
+
fastify.register(_formbody.default, this.options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.FormBodyParserPlugin = FormBodyParserPlugin;
|
package/lib/core/server.js
CHANGED
|
@@ -89,7 +89,9 @@ export class Server {
|
|
|
89
89
|
headers: req.headers,
|
|
90
90
|
setHeader: (k, v) => res.header(k, v),
|
|
91
91
|
redirect: undefined,
|
|
92
|
-
ws: req
|
|
92
|
+
ws: req,
|
|
93
|
+
req: req,
|
|
94
|
+
res: res
|
|
93
95
|
});
|
|
94
96
|
return;
|
|
95
97
|
}
|
|
@@ -117,7 +119,9 @@ export class Server {
|
|
|
117
119
|
headers: req.headers,
|
|
118
120
|
setHeader: (k, v) => res.header(k, v),
|
|
119
121
|
redirect: url => res.redirect(url),
|
|
120
|
-
ws: undefined
|
|
122
|
+
ws: undefined,
|
|
123
|
+
req: req,
|
|
124
|
+
res: res
|
|
121
125
|
});
|
|
122
126
|
return data;
|
|
123
127
|
}
|
package/lib/core/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { BasePlugin } from '../plugins/base';
|
|
3
3
|
import { BaseService } from '../services/base';
|
|
4
|
+
import { FastifyReply, FastifyRequest } from 'fastify';
|
|
4
5
|
import { yup } from 'vtils/validator';
|
|
5
6
|
import type { AsyncOrSync, LiteralUnion, OneOrMore, RequiredDeep } from 'vtils/types';
|
|
6
7
|
import type { DisposeService } from '../services/dispose';
|
|
@@ -65,6 +66,14 @@ export declare namespace XHandler {
|
|
|
65
66
|
* WS
|
|
66
67
|
*/
|
|
67
68
|
ws: SocketStream;
|
|
69
|
+
/**
|
|
70
|
+
* Fastify Request
|
|
71
|
+
*/
|
|
72
|
+
req: FastifyRequest;
|
|
73
|
+
/**
|
|
74
|
+
* Fastify Response
|
|
75
|
+
*/
|
|
76
|
+
res: FastifyReply;
|
|
68
77
|
}
|
|
69
78
|
type Handle<TReqData extends any = void, TResData extends any = void, TReqMethod extends Method = Method> = (
|
|
70
79
|
/**
|
package/lib/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './core/types';
|
|
|
12
12
|
export * from './plugins/base';
|
|
13
13
|
export * from './plugins/cors';
|
|
14
14
|
export * from './plugins/file_parser';
|
|
15
|
+
export * from './plugins/form_body_parser';
|
|
15
16
|
export * from './plugins/ws_parser';
|
|
16
17
|
export * from './plugins/xml_parser';
|
|
17
18
|
export * from './services/base';
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./core/types";
|
|
|
13
13
|
export * from "./plugins/base";
|
|
14
14
|
export * from "./plugins/cors";
|
|
15
15
|
export * from "./plugins/file_parser";
|
|
16
|
+
export * from "./plugins/form_body_parser";
|
|
16
17
|
export * from "./plugins/ws_parser";
|
|
17
18
|
export * from "./plugins/xml_parser";
|
|
18
19
|
export * from "./services/base";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormBodyPluginOptions } from '@fastify/formbody';
|
|
2
|
+
import { BasePlugin } from './base';
|
|
3
|
+
import { FastifyInstance } from 'fastify';
|
|
4
|
+
export interface FormBodyParserPluginOptions extends FormBodyPluginOptions {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* POST application/x-www-form-urlencoded 解析器插件
|
|
8
|
+
*/
|
|
9
|
+
export declare class FormBodyParserPlugin implements BasePlugin {
|
|
10
|
+
private options?;
|
|
11
|
+
constructor(options?: FormBodyParserPluginOptions);
|
|
12
|
+
register(fastify: FastifyInstance): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import FastifyFormBody from '@fastify/formbody';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* POST application/x-www-form-urlencoded 解析器插件
|
|
5
|
+
*/
|
|
6
|
+
export class FormBodyParserPlugin {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
register(fastify) {
|
|
12
|
+
fastify.register(FastifyFormBody, this.options);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayfong/x-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "lib/_cjs/index.js",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@fastify/formbody": "^6.0.0",
|
|
29
30
|
"@prisma/client": "^3.12.0",
|
|
30
31
|
"@types/bull": "^3.15.8",
|
|
31
32
|
"@types/busboy": "^0.3.2",
|