dx-server 0.5.8 → 0.5.10

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/README.md CHANGED
@@ -119,22 +119,20 @@ const serverChain = chain(
119
119
  app.use('/public', express.static('public'))
120
120
  }),
121
121
  authContext.chain(), // chain context will set the context value to authContext.value in every request
122
- router.post({// example of catching error for all /api/* routes
123
- async '/api'({next}) {
124
- try {
125
- await next()
126
- } catch (e) {
127
- if (e instanceof ServerError) setJson({// only app error message should be shown to user
128
- error: e.message,
129
- code: e.code,
130
- }, {status: e.status})
131
- else {// report system error
132
- console.error(e)
133
- setJson({
134
- message: 'internal server error',
135
- code: 'internal'
136
- }, {status: 500})
137
- }
122
+ router.post('/api', async ({next}) => {// example of catching error for all /api/* routes
123
+ try {
124
+ await next()
125
+ } catch (e) {
126
+ if (e instanceof ServerError) setJson({// only app error message should be shown to user
127
+ error: e.message,
128
+ code: e.code,
129
+ }, {status: e.status})
130
+ else {// report system error
131
+ console.error(e)
132
+ setJson({
133
+ message: 'internal server error',
134
+ code: 'internal'
135
+ }, {status: 500})
138
136
  }
139
137
  }
140
138
  }, {end: false}), // note: {end: false} is required to match all /api/* routes. This option is passed directly to path-to-regexp
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
3
  import { IncomingMessage } from 'node:http';
4
- import qs from 'qs';
5
4
  export interface BufferBodyOptions {
6
5
  bodyLimit: number;
7
6
  simplifyUrlEncodedBody?: boolean;
@@ -12,6 +11,6 @@ export declare function bufferFromReq(req: IncomingMessage, options?: Partial<Bu
12
11
  export declare function jsonFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<any>;
13
12
  export declare function rawFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<Buffer | undefined>;
14
13
  export declare function textFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<string | undefined>;
15
- export declare function urlEncodedFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<qs.ParsedQs | undefined>;
14
+ export declare function urlEncodedFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<any>;
16
15
  export declare function urlFromReq(req: IncomingMessage): URL;
17
- export declare function queryFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): qs.ParsedQs;
16
+ export declare function queryFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): any;
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
3
  import { IncomingMessage } from 'node:http';
4
- import qs from 'qs';
5
4
  export interface BufferBodyOptions {
6
5
  bodyLimit: number;
7
6
  simplifyUrlEncodedBody?: boolean;
@@ -12,6 +11,6 @@ export declare function bufferFromReq(req: IncomingMessage, options?: Partial<Bu
12
11
  export declare function jsonFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<any>;
13
12
  export declare function rawFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<Buffer | undefined>;
14
13
  export declare function textFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<string | undefined>;
15
- export declare function urlEncodedFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<qs.ParsedQs | undefined>;
14
+ export declare function urlEncodedFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): Promise<any>;
16
15
  export declare function urlFromReq(req: IncomingMessage): URL;
17
- export declare function queryFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): qs.ParsedQs;
16
+ export declare function queryFromReq(req: IncomingMessage, options?: Partial<BufferBodyOptions>): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dx-server",
3
- "version": "0.5.8",
3
+ "version": "0.5.10",
4
4
  "main": "./cjs/index.js",
5
5
  "homepage": "https://github.com/tranvansang/dx-server",
6
6
  "repository": "https://github.com/tranvansang/dx-server",