jmini 0.0.4 → 0.0.6
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/cjs/index.js +1 -479
- package/declare/server.d.ts +15 -14
- package/esm/server.js +1 -1
- package/package.json +1 -1
package/declare/server.d.ts
CHANGED
|
@@ -5,31 +5,32 @@ declare namespace Server {
|
|
|
5
5
|
interface Response extends express.Response {
|
|
6
6
|
return(p?: ReturnInput): Response;
|
|
7
7
|
}
|
|
8
|
-
type Path = string |
|
|
8
|
+
type Path = string | RegExp;
|
|
9
9
|
type Callback<A = Request, B = Response> = (req: A, res: B, next: express.NextFunction, error: Error) => void;
|
|
10
|
+
type RestArgs<A = Request, B = Response> = [path: Path, ...fns: Callback<A, B>[]];
|
|
10
11
|
type SetInput = [string, any];
|
|
11
|
-
type UseInput<A = Request, B = Response> = [Path] | [Path,
|
|
12
|
-
type RestInput<A = Request, B = Response> = [path: Path, ...fns: Callback<A, B>[]];
|
|
12
|
+
type UseInput<A = Request, B = Response> = [Path] | [Path, any] | RestArgs<A, B> | [Callback<A, B>];
|
|
13
13
|
type ReturnInput<T = any> = {
|
|
14
14
|
status?: number;
|
|
15
15
|
body?: T;
|
|
16
16
|
bodyStringify?: boolean;
|
|
17
17
|
};
|
|
18
|
-
type CustomMethods<A = Request, B = Response
|
|
19
|
-
set(...args: SetInput):
|
|
20
|
-
use(...args: UseInput<A, B>):
|
|
21
|
-
get(...args:
|
|
22
|
-
post(...args:
|
|
23
|
-
put(...args:
|
|
24
|
-
patch(...args:
|
|
25
|
-
delete(...args:
|
|
26
|
-
options(...args:
|
|
27
|
-
all(...args:
|
|
18
|
+
type CustomMethods<A = Request, B = Response> = {
|
|
19
|
+
set(...args: SetInput): Methods<A, B>;
|
|
20
|
+
use(...args: UseInput<A, B>): Methods<A, B>;
|
|
21
|
+
get(...args: RestArgs<A, B>): Methods<A, B>;
|
|
22
|
+
post(...args: RestArgs<A, B>): Methods<A, B>;
|
|
23
|
+
put(...args: RestArgs<A, B>): Methods<A, B>;
|
|
24
|
+
patch(...args: RestArgs<A, B>): Methods<A, B>;
|
|
25
|
+
delete(...args: RestArgs<A, B>): Methods<A, B>;
|
|
26
|
+
options(...args: RestArgs<A, B>): Methods<A, B>;
|
|
27
|
+
all(...args: RestArgs<A, B>): Methods<A, B>;
|
|
28
28
|
};
|
|
29
|
+
type PathRouterOmits = 'onPathRouter' | 'pathRouter' | 'exception';
|
|
29
30
|
type CustomExpress = Omit<express.Express, keyof CustomMethods>;
|
|
30
31
|
type Methods<A = Request, B = Response> = CustomExpress & CustomMethods<A, B> & {
|
|
31
32
|
onPathRouter(getRouter: (path: string) => express.Router): Methods<A, B>;
|
|
32
|
-
pathRouter(path: string): CustomMethods<A, B
|
|
33
|
+
pathRouter(path: string): Omit<CustomMethods<A, B>, PathRouterOmits>;
|
|
33
34
|
exception(fn: (err: any, req: A, res: B, next: express.NextFunction) => void): Methods<A, B>;
|
|
34
35
|
};
|
|
35
36
|
type FN = {
|
package/esm/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-ABA72NWU.js";import
|
|
1
|
+
import"./chunk-ABA72NWU.js";import h from"./core";const p=function(u){let t=u,r=null;return t.use((e,s,a)=>{let R=s;R.return=A=>{let{status:i=200,body:o={},bodyStringify:x=!0}=A||{},n=o;return x&&(h.is.string(o)||(n=JSON.stringify(o))),s.status(i).end(n)},a()}),t.onPathRouter=function(e){return r=e,this},t.pathRouter=function(e){if(!r)return;let s=r(e);return s.route(e),t.use(e,s),s},t.exception=function(e){return t.use(e),this},t};export{p as Server,p as default};
|