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.
@@ -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 | number | boolean | RegExp | void;
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, Path] | RestInput | [Callback<A, B>];
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, E extends string = ''> = {
19
- set(...args: SetInput): Omit<Methods<A, B>, E>;
20
- use(...args: UseInput<A, B>): Omit<Methods<A, B>, E>;
21
- get(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
22
- post(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
23
- put(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
24
- patch(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
25
- delete(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
26
- options(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
27
- all(...args: RestInput<A, B>): Omit<Methods<A, B>, E>;
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, 'setRouter' | 'pathRouter'>;
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 A from"./core";import B from"express";const n=function(u){let t=u,r=null;return t.use((e,s,a)=>{let i=s;i.return=R=>{let{status:x=200,body:o={},bodyStringify:h=!0}=R||{},p=o;return h&&(A.is.string(o)||(p=JSON.stringify(o))),s.status(x).end(p)},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};let d=n(B()).pathRouter("test");d.post("test");export{n as Server,n as default};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmini",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "minified JavaScript Framework",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",