@clairejs/server 3.22.4 → 3.22.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/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  ## Change Log
2
2
 
3
- #### 3.22.4:
3
+ #### 3.22.6:
4
4
 
5
+ - fix Lambda Wrapper resolve job scheduler
5
6
  - add log to debug aws cron
6
7
 
7
8
  #### 3.22.3:
@@ -33,7 +33,6 @@ 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));
37
36
  await this.executeJob(jobInfo);
38
37
  }
39
38
  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;
@@ -1,8 +1,8 @@
1
1
  import { getServiceProvider, HttpMethod, SocketMethod, Errors } from "@clairejs/core";
2
2
  import { AbstractHttpRequestHandler } from "../http/controller/AbstractHttpRequestHandler";
3
- import { AwsJobScheduler } from "../job/AwsJobScheduler";
4
- import { CRON_REQUEST_METHOD } from "../job/interfaces";
5
3
  import { AbstractServerSocketManager } from "../socket/AbstractServerSocketManager";
4
+ import { CRON_REQUEST_METHOD } from "../job/interfaces";
5
+ import { AbstractJobScheduler } from "../job/AbstractJobScheduler";
6
6
  const convertCorsToHeaders = (origin, cors) => {
7
7
  const headers = {};
8
8
  if (cors?.credentials) {
@@ -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,24 +75,23 @@ 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) {
85
81
  this._server = await this.serverFactory();
86
- await this.injector.initInstances();
82
+ const injector = getServiceProvider().getInjector();
83
+ this.socketManager = injector.resolveOptional(AbstractServerSocketManager);
84
+ this.httpRequestHandler = injector.resolveOptional(AbstractHttpRequestHandler);
85
+ this.jobScheduler = injector.resolveOptional(AbstractJobScheduler);
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");
93
92
  await this.bootServer();
94
93
  //-- handle http otherwise
95
94
  const requestOptions = this.requestMapper(event);
96
- console.log("request optons", JSON.stringify(requestOptions));
97
95
  if (!requestOptions) {
98
96
  throw Errors.SYSTEM_ERROR("Cannot resolve event");
99
97
  }
@@ -102,7 +100,6 @@ export class LambdaWrapper {
102
100
  return toApiGatewayFormat({ code: 200, headers: corsHeaders, cookies: {} });
103
101
  }
104
102
  if (requestOptions.method === CRON_REQUEST_METHOD) {
105
- console.log("request handle cron", !!this.jobScheduler);
106
103
  await this.jobScheduler?.handleCron(requestOptions.body);
107
104
  return toApiGatewayFormat({ code: 200, headers: corsHeaders, cookies: {} });
108
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/server",
3
- "version": "3.22.4",
3
+ "version": "3.22.6",
4
4
  "description": "Claire server NodeJs framework written in Typescript.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",