@tsed/platform-middlewares 7.0.0-alpha.1 → 7.0.0-beta.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.
Files changed (70) hide show
  1. package/lib/cjs/constants/constants.js +34 -0
  2. package/lib/cjs/constants/constants.js.map +1 -0
  3. package/lib/cjs/decorators/authOptions.js +44 -0
  4. package/lib/cjs/decorators/authOptions.js.map +1 -0
  5. package/lib/cjs/decorators/middleware.js +17 -0
  6. package/lib/cjs/decorators/middleware.js.map +1 -0
  7. package/lib/cjs/decorators/use.js +43 -0
  8. package/lib/cjs/decorators/use.js.map +1 -0
  9. package/lib/cjs/decorators/useAfter.js +46 -0
  10. package/lib/cjs/decorators/useAfter.js.map +1 -0
  11. package/lib/cjs/decorators/useAuth.js +45 -0
  12. package/lib/cjs/decorators/useAuth.js.map +1 -0
  13. package/lib/cjs/decorators/useBefore.js +45 -0
  14. package/lib/cjs/decorators/useBefore.js.map +1 -0
  15. package/lib/cjs/decorators/useBeforeEach.js +40 -0
  16. package/lib/cjs/decorators/useBeforeEach.js.map +1 -0
  17. package/lib/cjs/domain/MiddlewareMethods.js +3 -0
  18. package/lib/cjs/domain/MiddlewareMethods.js.map +1 -0
  19. package/lib/cjs/domain/PlatformMiddlewareSettings.js +3 -0
  20. package/lib/cjs/domain/PlatformMiddlewareSettings.js.map +1 -0
  21. package/lib/cjs/index.js +18 -0
  22. package/lib/cjs/index.js.map +1 -0
  23. package/lib/cjs/package.json +3 -0
  24. package/lib/cjs/utils/getMiddlewaresForHook.js +26 -0
  25. package/lib/cjs/utils/getMiddlewaresForHook.js.map +1 -0
  26. package/lib/esm/constants/constants.js +31 -0
  27. package/lib/esm/constants/constants.js.map +1 -0
  28. package/lib/esm/decorators/authOptions.js +40 -0
  29. package/lib/esm/decorators/authOptions.js.map +1 -0
  30. package/lib/esm/decorators/middleware.js +13 -0
  31. package/lib/esm/decorators/middleware.js.map +1 -0
  32. package/lib/esm/decorators/use.js +39 -0
  33. package/lib/esm/decorators/use.js.map +1 -0
  34. package/lib/esm/decorators/useAfter.js +42 -0
  35. package/lib/esm/decorators/useAfter.js.map +1 -0
  36. package/lib/esm/decorators/useAuth.js +41 -0
  37. package/lib/esm/decorators/useAuth.js.map +1 -0
  38. package/lib/esm/decorators/useBefore.js +41 -0
  39. package/lib/esm/decorators/useBefore.js.map +1 -0
  40. package/lib/esm/decorators/useBeforeEach.js +36 -0
  41. package/lib/esm/decorators/useBeforeEach.js.map +1 -0
  42. package/lib/esm/domain/MiddlewareMethods.js +2 -0
  43. package/lib/esm/domain/MiddlewareMethods.js.map +1 -0
  44. package/lib/esm/domain/PlatformMiddlewareSettings.js +2 -0
  45. package/lib/esm/domain/PlatformMiddlewareSettings.js.map +1 -0
  46. package/lib/esm/index.js +15 -0
  47. package/lib/esm/index.js.map +1 -0
  48. package/lib/esm/package.json +3 -0
  49. package/lib/esm/utils/getMiddlewaresForHook.js +22 -0
  50. package/lib/esm/utils/getMiddlewaresForHook.js.map +1 -0
  51. package/lib/{constants/index.d.ts → types/constants/constants.d.ts} +0 -0
  52. package/lib/{decorators → types/decorators}/authOptions.d.ts +0 -0
  53. package/lib/{decorators → types/decorators}/middleware.d.ts +0 -0
  54. package/lib/{decorators → types/decorators}/use.d.ts +0 -0
  55. package/lib/{decorators → types/decorators}/useAfter.d.ts +0 -0
  56. package/lib/{decorators → types/decorators}/useAuth.d.ts +0 -0
  57. package/lib/{decorators → types/decorators}/useBefore.d.ts +0 -0
  58. package/lib/{decorators → types/decorators}/useBeforeEach.d.ts +0 -0
  59. package/lib/{domain → types/domain}/MiddlewareMethods.d.ts +0 -0
  60. package/lib/{domain → types/domain}/PlatformMiddlewareSettings.d.ts +0 -0
  61. package/lib/{index.d.ts → types/index.d.ts} +5 -1
  62. package/lib/{utils → types/utils}/getMiddlewaresForHook.d.ts +0 -0
  63. package/package.json +31 -14
  64. package/readme.md +1 -2
  65. package/tsconfig.compile.esm.json +12 -0
  66. package/lib/index.js +0 -333
  67. package/lib/index.js.map +0 -1
  68. package/lib/index.modern.js +0 -326
  69. package/lib/index.modern.js.map +0 -1
  70. package/lib/utils/mapUseOptions.d.ts +0 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAfter.js","sourceRoot":"","sources":["../../../src/decorators/useAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AACpE,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,IAAW;IACrC,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;QACzC,QAAQ,MAAM,CAAC,aAAa,EAAE;YAC5B,KAAK,cAAc,CAAC,MAAM;gBACxB,MAAM,QAAQ,GAAG,MAAM,CAAC;gBACxB,QAAQ,CAAC,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;gBAEnE,MAAM;YAER,KAAK,cAAc,CAAC,KAAK;gBACvB,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;gBAE1D,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE;oBAC9B,GAAG,WAAW;oBACd,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;iBACrD,CAAC,CAAC;gBACH,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;SAC5D;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseAfter(Middleware1)\n * export class Ctrl {\n *\n * @Get('/')\n * @UseAfter(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseAfter(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n const endpoint = entity;\n endpoint.afterMiddlewares = args.concat(endpoint.afterMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useAfter: [...args, ...(middlewares.useAfter || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAfter, parameters);\n }\n });\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, StoreFn, UnsupportedDecoratorType, useDecorators } from "@tsed/core";
2
+ import { AuthOptions } from "./authOptions.js";
3
+ import { UseBefore } from "./useBefore.js";
4
+ /**
5
+ * Use custom authentication strategy on your endpoint.
6
+ *
7
+ * ```typescript
8
+ * @Controller('/mypath')
9
+ * @UseAuth(MyAuthStrategy)
10
+ * class MyCtrl {
11
+ *
12
+ * @Get('/')
13
+ * @UseAuth(MyAuthStrategy, {role: 'admin'})
14
+ * public getResource(){}
15
+ * }
16
+ * ```
17
+ *
18
+ * @param guardAuth {Type<any>} A middleware which implement a custom auth strategy
19
+ * @param options {Object} Object passed to the customer auth strategy
20
+ * @returns {Function}
21
+ * @decorator
22
+ * @operation
23
+ */
24
+ export function UseAuth(guardAuth, options = {}) {
25
+ return (...args) => {
26
+ switch (decoratorTypeOf(args)) {
27
+ case DecoratorTypes.METHOD:
28
+ return useDecorators(StoreFn((store) => {
29
+ if (!store.has(guardAuth)) {
30
+ return UseBefore(guardAuth);
31
+ }
32
+ }), AuthOptions(guardAuth, options))(...args);
33
+ case DecoratorTypes.CLASS:
34
+ decorateMethodsOf(args[0], UseAuth(guardAuth, options));
35
+ break;
36
+ default:
37
+ throw new UnsupportedDecoratorType(UseAuth, args);
38
+ }
39
+ };
40
+ }
41
+ //# sourceMappingURL=useAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../../src/decorators/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,eAAe,EACf,cAAc,EAEd,OAAO,EAEP,wBAAwB,EACxB,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAC,SAAoB,EAAE,UAAmC,EAAE;IACjF,OAAO,CAAI,GAAG,IAAyB,EAAqC,EAAE;QAC5E,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,MAAM;gBACxB,OAAO,aAAa,CAClB,OAAO,CAAC,CAAC,KAAY,EAAE,EAAE;oBACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;wBACzB,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;qBAC7B;gBACH,CAAC,CAAC,EACF,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAChC,CAAC,GAAG,IAAI,CAAC,CAAC;YAEb,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;gBACxD,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACrD;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n decorateMethodsOf,\n DecoratorParameters,\n decoratorTypeOf,\n DecoratorTypes,\n Store,\n StoreFn,\n Type,\n UnsupportedDecoratorType,\n useDecorators\n} from \"@tsed/core\";\nimport {AuthOptions} from \"./authOptions\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Use custom authentication strategy on your endpoint.\n *\n * ```typescript\n * @Controller('/mypath')\n * @UseAuth(MyAuthStrategy)\n * class MyCtrl {\n *\n * @Get('/')\n * @UseAuth(MyAuthStrategy, {role: 'admin'})\n * public getResource(){}\n * }\n * ```\n *\n * @param guardAuth {Type<any>} A middleware which implement a custom auth strategy\n * @param options {Object} Object passed to the customer auth strategy\n * @returns {Function}\n * @decorator\n * @operation\n */\nexport function UseAuth(guardAuth: Type<any>, options: Record<string, unknown> = {}): Function {\n return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.METHOD:\n return useDecorators(\n StoreFn((store: Store) => {\n if (!store.has(guardAuth)) {\n return UseBefore(guardAuth);\n }\n }),\n AuthOptions(guardAuth, options)\n )(...args);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], UseAuth(guardAuth, options));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAuth, args);\n }\n };\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import { DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
+ import { JsonEntityFn } from "@tsed/schema";
3
+ /**
4
+ * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when
5
+ * the base of the requested path matches `path.
6
+ *
7
+ * ```typescript
8
+ * @Controller('/')
9
+ * @UseBefore(Middleware1) // called only one time before all endpoint
10
+ * export class Ctrl {
11
+ *
12
+ * @Get('/')
13
+ * @UseBefore(Middleware2)
14
+ * get() { }
15
+ * }
16
+ * ```
17
+ *
18
+ * @returns {function(any, any, any): *}
19
+ * @param args
20
+ * @decorator
21
+ * @operation
22
+ */
23
+ export function UseBefore(...args) {
24
+ return JsonEntityFn((entity, parameters) => {
25
+ switch (entity.decoratorType) {
26
+ case DecoratorTypes.METHOD:
27
+ entity.beforeMiddlewares = args.concat(entity.beforeMiddlewares);
28
+ break;
29
+ case DecoratorTypes.CLASS:
30
+ const middlewares = entity.store.get("middlewares") || {};
31
+ entity.store.set("middlewares", {
32
+ ...middlewares,
33
+ useBefore: [...args, ...(middlewares.useBefore || [])]
34
+ });
35
+ break;
36
+ default:
37
+ throw new UnsupportedDecoratorType(UseBefore, parameters);
38
+ }
39
+ });
40
+ }
41
+ //# sourceMappingURL=useBefore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBefore.js","sourceRoot":"","sources":["../../../src/decorators/useBefore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AACpE,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,IAAW;IACtC,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;QACzC,QAAQ,MAAM,CAAC,aAAa,EAAE;YAC5B,KAAK,cAAc,CAAC,MAAM;gBACxB,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;gBAEjE,MAAM;YAER,KAAK,cAAc,CAAC,KAAK;gBACvB,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;gBAE1D,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE;oBAC9B,GAAG,WAAW;oBACd,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;iBACvD,CAAC,CAAC;gBACH,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;SAC7D;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBefore(Middleware1) // called only one time before all endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * @UseBefore(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBefore(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n entity.beforeMiddlewares = args.concat(entity.beforeMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useBefore: [...args, ...(middlewares.useBefore || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBefore, parameters);\n }\n });\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
+ import { UseBefore } from "./useBefore.js";
3
+ /**
4
+ * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when
5
+ * the base of the requested path matches `path.
6
+ *
7
+ * ```typescript
8
+ * @Controller('/')
9
+ * @UseBeforeEach(Middleware1) // Called before each endpoint
10
+ * export class Ctrl {
11
+ *
12
+ * @Get('/')
13
+ * get() { }
14
+ * }
15
+ *
16
+ * ```
17
+ *
18
+ * @returns {Function}
19
+ * @param args
20
+ * @decorator
21
+ * @operation
22
+ */
23
+ export function UseBeforeEach(...args) {
24
+ return (...decoratorArgs) => {
25
+ switch (decoratorTypeOf(decoratorArgs)) {
26
+ case DecoratorTypes.METHOD:
27
+ return UseBefore(...args)(...decoratorArgs);
28
+ case DecoratorTypes.CLASS:
29
+ decorateMethodsOf(decoratorArgs[0], UseBefore(...args));
30
+ break;
31
+ default:
32
+ throw new UnsupportedDecoratorType(UseBeforeEach, decoratorArgs);
33
+ }
34
+ };
35
+ }
36
+ //# sourceMappingURL=useBeforeEach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBeforeEach.js","sourceRoot":"","sources":["../../../src/decorators/useBeforeEach.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAuB,eAAe,EAAE,cAAc,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AAC7H,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,IAAW;IAC1C,OAAO,CAAI,GAAG,aAAkC,EAAqC,EAAE;QACrF,QAAQ,eAAe,CAAC,aAAa,CAAC,EAAE;YACtC,KAAK,cAAc,CAAC,MAAM;gBACxB,OAAO,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC;YAE9C,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;gBACxD,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;SACpE;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {decorateMethodsOf, DecoratorParameters, decoratorTypeOf, DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBeforeEach(Middleware1) // Called before each endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBeforeEach(...args: any[]): Function {\n return <T>(...decoratorArgs: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(decoratorArgs)) {\n case DecoratorTypes.METHOD:\n return UseBefore(...args)(...decoratorArgs);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(decoratorArgs[0], UseBefore(...args));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBeforeEach, decoratorArgs);\n }\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MiddlewareMethods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MiddlewareMethods.js","sourceRoot":"","sources":["../../../src/domain/MiddlewareMethods.ts"],"names":[],"mappings":"","sourcesContent":["export interface MiddlewareMethods {\n use(...args: any[]): void | any | Promise<any>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PlatformMiddlewareSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformMiddlewareSettings.js","sourceRoot":"","sources":["../../../src/domain/PlatformMiddlewareSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Env, Type} from \"@tsed/core\";\n\nexport type PlatformMiddlewareLoadingOptions = {env?: Env; use: Function | Type<any>; hook?: string};\nexport type PlatformMiddlewareSettings = Function | Type<any> | PlatformMiddlewareLoadingOptions | any;\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n /**\n * Load middlewares on the $beforeRoutesInit hook (or on the specified hook event name).\n */\n middlewares: PlatformMiddlewareSettings[];\n }\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./constants/constants.js";
5
+ export * from "./decorators/authOptions.js";
6
+ export * from "./decorators/middleware.js";
7
+ export * from "./decorators/use.js";
8
+ export * from "./decorators/useAfter.js";
9
+ export * from "./decorators/useAuth.js";
10
+ export * from "./decorators/useBefore.js";
11
+ export * from "./decorators/useBeforeEach.js";
12
+ export * from "./domain/MiddlewareMethods.js";
13
+ export * from "./domain/PlatformMiddlewareSettings.js";
14
+ export * from "./utils/getMiddlewaresForHook.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./constants/constants\";\nexport * from \"./decorators/authOptions\";\nexport * from \"./decorators/middleware\";\nexport * from \"./decorators/use\";\nexport * from \"./decorators/useAfter\";\nexport * from \"./decorators/useAuth\";\nexport * from \"./decorators/useBefore\";\nexport * from \"./decorators/useBeforeEach\";\nexport * from \"./domain/MiddlewareMethods\";\nexport * from \"./domain/PlatformMiddlewareSettings\";\nexport * from \"./utils/getMiddlewaresForHook\";\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,22 @@
1
+ import { isFunction } from "@tsed/core";
2
+ export function getMiddlewaresForHook(hook, settings, defaultHook = "") {
3
+ const { env, middlewares = [] } = settings;
4
+ return middlewares
5
+ .map((middleware) => {
6
+ return isFunction(middleware)
7
+ ? {
8
+ env,
9
+ hook: defaultHook,
10
+ use: middleware
11
+ }
12
+ : {
13
+ env,
14
+ hook: defaultHook,
15
+ ...middleware
16
+ };
17
+ })
18
+ .filter((options) => {
19
+ return options.use && options.env === env && options.hook === hook;
20
+ });
21
+ }
22
+ //# sourceMappingURL=getMiddlewaresForHook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMiddlewaresForHook.js","sourceRoot":"","sources":["../../../src/utils/getMiddlewaresForHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAGtC,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,QAA4B,EAAE,WAAW,GAAG,EAAE;IAChG,MAAM,EAAC,GAAG,EAAE,WAAW,GAAG,EAAE,EAAC,GAAG,QAAQ,CAAC;IAEzC,OAAO,WAAW;SACf,GAAG,CAAmC,CAAC,UAAU,EAAE,EAAE;QACpD,OAAO,UAAU,CAAC,UAAU,CAAC;YAC3B,CAAC,CAAC;gBACE,GAAG;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,EAAE,UAAU;aAChB;YACH,CAAC,CAAC;gBACE,GAAG;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,UAAU;aACd,CAAC;IACR,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {isFunction} from \"@tsed/core\";\nimport {PlatformMiddlewareLoadingOptions} from \"../domain/PlatformMiddlewareSettings\";\n\nexport function getMiddlewaresForHook(hook: string, settings: TsED.Configuration, defaultHook = \"\") {\n const {env, middlewares = []} = settings;\n\n return middlewares\n .map<PlatformMiddlewareLoadingOptions>((middleware) => {\n return isFunction(middleware)\n ? {\n env,\n hook: defaultHook,\n use: middleware\n }\n : {\n env,\n hook: defaultHook,\n ...middleware\n };\n })\n .filter((options) => {\n return options.use && options.env === env && options.hook === hook;\n });\n}\n"]}
File without changes
@@ -1,5 +1,9 @@
1
- export * from "./decorators/middleware";
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./constants/constants";
2
5
  export * from "./decorators/authOptions";
6
+ export * from "./decorators/middleware";
3
7
  export * from "./decorators/use";
4
8
  export * from "./decorators/useAfter";
5
9
  export * from "./decorators/useAuth";
package/package.json CHANGED
@@ -1,36 +1,53 @@
1
1
  {
2
2
  "name": "@tsed/platform-middlewares",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-beta.10",
4
4
  "description": "Middlewares module for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
7
- "main": "./lib/index.js",
8
- "typings": "./lib/index.d.ts",
7
+ "main": "./lib/cjs/index.js",
8
+ "module": "./lib/esm/index.js",
9
+ "typings": "./lib/types/index.d.ts",
9
10
  "exports": {
10
- "require": "./lib/index.js",
11
- "default": "./lib/index.modern.js"
11
+ "types": "./lib/types/index.d.ts",
12
+ "import": "./lib/esm/index.js",
13
+ "require": "./lib/cjs/index.js",
14
+ "default": "./lib/esm/index.js"
12
15
  },
13
16
  "scripts": {
14
- "build": "microbundle --target node --no-compress --format modern,cjs --tsconfig ./tsconfig.compile.json"
17
+ "build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
18
+ "build:cjs": "tsc --build tsconfig.compile.json",
19
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
20
+ "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\""
15
21
  },
16
22
  "dependencies": {
17
- "tslib": "2.2.0"
23
+ "tslib": "2.3.1"
18
24
  },
19
25
  "devDependencies": {
20
- "@tsed/core": "7.0.0-alpha.1",
21
- "@tsed/di": "7.0.0-alpha.1",
22
- "@tsed/schema": "7.0.0-alpha.1"
26
+ "@tsed/core": "7.0.0-beta.10",
27
+ "@tsed/di": "7.0.0-beta.10",
28
+ "@tsed/schema": "7.0.0-beta.10"
23
29
  },
24
30
  "peerDependencies": {
25
- "@tsed/core": "^7.0.0-alpha.1",
26
- "@tsed/di": "^7.0.0-alpha.1",
27
- "@tsed/schema": "^7.0.0-alpha.1"
31
+ "@tsed/core": "^7.0.0-beta.10",
32
+ "@tsed/di": "^7.0.0-beta.10",
33
+ "@tsed/schema": "^7.0.0-beta.10"
34
+ },
35
+ "peerDependenciesMeta": {
36
+ "@tsed/core": {
37
+ "optional": true
38
+ },
39
+ "@tsed/di": {
40
+ "optional": true
41
+ },
42
+ "@tsed/schema": {
43
+ "optional": true
44
+ }
28
45
  },
29
46
  "repository": "https://github.com/tsedio/tsed",
30
47
  "bugs": {
31
48
  "url": "https://github.com/tsedio/tsed/issues"
32
49
  },
33
- "homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/platform/platform-middlewares",
50
+ "homepage": "https://github.com/tsedio/tsed/tree/beta/packages/platform/platform-middlewares",
34
51
  "author": "Romain Lenzotti",
35
52
  "license": "MIT"
36
53
  }
package/readme.md CHANGED
@@ -36,18 +36,17 @@ npm install --save @tsed/platform-middlewares
36
36
  ```
37
37
 
38
38
  ## Contributors
39
+
39
40
  Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html).
40
41
 
41
42
  <a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
42
43
 
43
-
44
44
  ## Backers
45
45
 
46
46
  Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
47
47
 
48
48
  <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
49
49
 
50
-
51
50
  ## Sponsors
52
51
 
53
52
  Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "./tsconfig.compile.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types"
10
+ },
11
+ "exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
12
+ }