@clairejs/server 3.22.3 → 3.22.5

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
@@ -1,5 +1,9 @@
1
1
  ## Change Log
2
2
 
3
+ #### 3.22.5:
4
+
5
+ - add log to debug aws cron
6
+
3
7
  #### 3.22.3:
4
8
 
5
9
  - fix AwsCron expression
@@ -33,6 +33,7 @@ let AwsJobScheduler = class AwsJobScheduler extends AbstractJobScheduler {
33
33
  }
34
34
  async handleCron(jobInfo) {
35
35
  this.logger.debug(`Handle cron`, jobInfo);
36
+ console.log("handling cron", JSON.stringify(jobInfo));
36
37
  await this.executeJob(jobInfo);
37
38
  }
38
39
  async afterJob(_job, _tx) {
@@ -12,10 +12,9 @@ export declare class LambdaWrapper {
12
12
  protected readonly serverFactory: () => Promise<ClaireServer>;
13
13
  protected readonly requestMapper: (event: any) => RequestOptions | undefined;
14
14
  protected readonly config?: LambdaWrapperConfig | undefined;
15
- private readonly injector;
16
- private readonly httpRequestHandler?;
17
- private readonly socketManager?;
18
- private readonly jobScheduler?;
15
+ private httpRequestHandler?;
16
+ private socketManager?;
17
+ private jobScheduler?;
19
18
  private _server?;
20
19
  constructor(serverFactory: () => Promise<ClaireServer>, requestMapper: (event: any) => RequestOptions | undefined, config?: LambdaWrapperConfig | undefined);
21
20
  private bootServer;
@@ -66,7 +66,6 @@ export class LambdaWrapper {
66
66
  serverFactory;
67
67
  requestMapper;
68
68
  config;
69
- injector = getServiceProvider().getInjector();
70
69
  httpRequestHandler;
71
70
  socketManager;
72
71
  jobScheduler;
@@ -76,22 +75,25 @@ export class LambdaWrapper {
76
75
  this.requestMapper = requestMapper;
77
76
  this.config = config;
78
77
  this.handler = this.handler.bind(this);
79
- this.socketManager = this.injector.resolveOptional(AbstractServerSocketManager);
80
- this.httpRequestHandler = this.injector.resolveOptional(AbstractHttpRequestHandler);
81
- this.jobScheduler = this.injector.resolveOptional(AwsJobScheduler);
82
78
  }
83
79
  async bootServer() {
84
80
  if (!this._server) {
81
+ const injector = getServiceProvider().getInjector();
85
82
  this._server = await this.serverFactory();
86
- await this.injector.initInstances();
83
+ this.socketManager = injector.resolveOptional(AbstractServerSocketManager);
84
+ this.httpRequestHandler = injector.resolveOptional(AbstractHttpRequestHandler);
85
+ this.jobScheduler = injector.resolveOptional(AwsJobScheduler);
86
+ await injector.initInstances();
87
87
  this.socketManager?.configure();
88
88
  await this._server.init();
89
89
  }
90
90
  }
91
91
  async handler(event) {
92
+ console.log("lambda wrapper handler");
92
93
  await this.bootServer();
93
94
  //-- handle http otherwise
94
95
  const requestOptions = this.requestMapper(event);
96
+ console.log("request optons", JSON.stringify(requestOptions));
95
97
  if (!requestOptions) {
96
98
  throw Errors.SYSTEM_ERROR("Cannot resolve event");
97
99
  }
@@ -100,6 +102,7 @@ export class LambdaWrapper {
100
102
  return toApiGatewayFormat({ code: 200, headers: corsHeaders, cookies: {} });
101
103
  }
102
104
  if (requestOptions.method === CRON_REQUEST_METHOD) {
105
+ console.log("request handle cron", !!this.jobScheduler);
103
106
  await this.jobScheduler?.handleCron(requestOptions.body);
104
107
  return toApiGatewayFormat({ code: 200, headers: corsHeaders, cookies: {} });
105
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/server",
3
- "version": "3.22.3",
3
+ "version": "3.22.5",
4
4
  "description": "Claire server NodeJs framework written in Typescript.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",