@jayfong/x-server 2.75.0 → 2.75.1

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.
@@ -1,68 +1,68 @@
1
- import * as handlers from './handlers'
2
- import { Handler, XServer } from '@jayfong/x-server'
1
+ import { Handler, XServer } from '@jayfong/x-server';
2
+ import * as handlers from './handlers';
3
3
 
4
4
  const basePathWithHandlers: Array<[string, Record<string, Handler>]> = [
5
- // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**', '!**/*.test.*'], (f, _) => `['${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}', handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__ as any],`)
5
+ // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**', '!**/*.test.*'], (f, _) => `['${(f.path+'/').replace(/@dev/g, '').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}', handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__ as any],`)
6
6
  // @endindex
7
- ]
7
+ ];
8
8
 
9
9
  // https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
10
10
  type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
11
11
  k: infer I,
12
12
  ) => void
13
13
  ? I
14
- : never
14
+ : never;
15
15
  type RouteMap = {
16
16
  // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**', '!**/*.test.*'], (f, _) => `'${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}': typeof handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__,`)
17
17
  // @endindex
18
- }
18
+ };
19
19
  export type HandlerMap = UnionToIntersection<
20
20
  {
21
21
  [K in keyof RouteMap]: {
22
22
  [X in keyof RouteMap[K]]: {
23
- [Y in `${K}${X & string}`]: RouteMap[K][X]
24
- }
25
- }[keyof RouteMap[K]]
23
+ [Y in `${K}${X & string}`]: RouteMap[K][X];
24
+ };
25
+ }[keyof RouteMap[K]];
26
26
  }[keyof RouteMap]
27
- >
28
- export type HandlerPath = keyof HandlerMap
27
+ >;
28
+ export type HandlerPath = keyof HandlerMap;
29
29
  export type HandlerMetaMap = {
30
30
  [K in HandlerPath]: HandlerMap[K] extends Handler<infer X, infer Y, infer Z>
31
31
  ? {
32
- payload: X
33
- result: Y
34
- method: Z
32
+ payload: X;
33
+ result: Y;
34
+ method: Z;
35
35
  }
36
- : {}
37
- }
36
+ : {};
37
+ };
38
38
  export type HandlerPayloadMap = {
39
39
  // @ts-ignore
40
- [K in HandlerPath]: HandlerMetaMap[K]['payload']
41
- }
40
+ [K in HandlerPath]: HandlerMetaMap[K]['payload'];
41
+ };
42
42
  export type HandlerResultMap = {
43
43
  // @ts-ignore
44
- [K in HandlerPath]: HandlerMetaMap[K]['result']
45
- }
44
+ [K in HandlerPath]: HandlerMetaMap[K]['result'];
45
+ };
46
46
  export type HandlerMethodMap = {
47
47
  // @ts-ignore
48
- [K in HandlerPath]: HandlerMetaMap[K]['method']
49
- }
48
+ [K in HandlerPath]: HandlerMetaMap[K]['method'];
49
+ };
50
50
 
51
51
  export const routes: XServer.Route[] = basePathWithHandlers.reduce<
52
52
  XServer.Route[]
53
53
  >((res, item) => {
54
54
  const validHandlerNames = Object.keys(item[1]).filter(
55
55
  name => !name.startsWith('_') && name !== 'default',
56
- )
56
+ );
57
57
  for (const handlerName of validHandlerNames) {
58
- const path = item[1][handlerName].options.requestPath || handlerName
59
- const paths = Array.isArray(path) ? path : [path]
58
+ const path = item[1][handlerName].options.requestPath || handlerName;
59
+ const paths = Array.isArray(path) ? path : [path];
60
60
  for (const path of paths) {
61
61
  res.push({
62
62
  path: `${item[0]}${path}`,
63
63
  handler: item[1][handlerName],
64
- })
64
+ });
65
65
  }
66
66
  }
67
- return res
68
- }, [])
67
+ return res;
68
+ }, []);
@@ -1,68 +1,68 @@
1
- import * as handlers from './handlers'
2
- import { Handler, XServer } from '@jayfong/x-server'
1
+ import { Handler, XServer } from '@jayfong/x-server';
2
+ import * as handlers from './handlers';
3
3
 
4
4
  const basePathWithHandlers: Array<[string, Record<string, Handler>]> = [
5
- // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**', '!**/*.test.*'], (f, _) => `['${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}', handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__ as any],`)
5
+ // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**', '!**/*.test.*'], (f, _) => `['${(f.path+'/').replace(/@dev/g, '').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}', handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__ as any],`)
6
6
  // @endindex
7
- ]
7
+ ];
8
8
 
9
9
  // https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
10
10
  type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
11
11
  k: infer I,
12
12
  ) => void
13
13
  ? I
14
- : never
14
+ : never;
15
15
  type RouteMap = {
16
16
  // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**', '!**/*.test.*'], (f, _) => `'${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}': typeof handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__,`)
17
17
  // @endindex
18
- }
18
+ };
19
19
  export type HandlerMap = UnionToIntersection<
20
20
  {
21
21
  [K in keyof RouteMap]: {
22
22
  [X in keyof RouteMap[K]]: {
23
- [Y in `${K}${X & string}`]: RouteMap[K][X]
24
- }
25
- }[keyof RouteMap[K]]
23
+ [Y in `${K}${X & string}`]: RouteMap[K][X];
24
+ };
25
+ }[keyof RouteMap[K]];
26
26
  }[keyof RouteMap]
27
- >
28
- export type HandlerPath = keyof HandlerMap
27
+ >;
28
+ export type HandlerPath = keyof HandlerMap;
29
29
  export type HandlerMetaMap = {
30
30
  [K in HandlerPath]: HandlerMap[K] extends Handler<infer X, infer Y, infer Z>
31
31
  ? {
32
- payload: X
33
- result: Y
34
- method: Z
32
+ payload: X;
33
+ result: Y;
34
+ method: Z;
35
35
  }
36
- : {}
37
- }
36
+ : {};
37
+ };
38
38
  export type HandlerPayloadMap = {
39
39
  // @ts-ignore
40
- [K in HandlerPath]: HandlerMetaMap[K]['payload']
41
- }
40
+ [K in HandlerPath]: HandlerMetaMap[K]['payload'];
41
+ };
42
42
  export type HandlerResultMap = {
43
43
  // @ts-ignore
44
- [K in HandlerPath]: HandlerMetaMap[K]['result']
45
- }
44
+ [K in HandlerPath]: HandlerMetaMap[K]['result'];
45
+ };
46
46
  export type HandlerMethodMap = {
47
47
  // @ts-ignore
48
- [K in HandlerPath]: HandlerMetaMap[K]['method']
49
- }
48
+ [K in HandlerPath]: HandlerMetaMap[K]['method'];
49
+ };
50
50
 
51
51
  export const routes: XServer.Route[] = basePathWithHandlers.reduce<
52
52
  XServer.Route[]
53
53
  >((res, item) => {
54
54
  const validHandlerNames = Object.keys(item[1]).filter(
55
55
  name => !name.startsWith('_') && name !== 'default',
56
- )
56
+ );
57
57
  for (const handlerName of validHandlerNames) {
58
- const path = item[1][handlerName].options.requestPath || handlerName
59
- const paths = Array.isArray(path) ? path : [path]
58
+ const path = item[1][handlerName].options.requestPath || handlerName;
59
+ const paths = Array.isArray(path) ? path : [path];
60
60
  for (const path of paths) {
61
61
  res.push({
62
62
  path: `${item[0]}${path}`,
63
63
  handler: item[1][handlerName],
64
- })
64
+ });
65
65
  }
66
66
  }
67
- return res
68
- }, [])
67
+ return res;
68
+ }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.75.0",
3
+ "version": "2.75.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",