@clairejs/server 3.28.4 → 3.28.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,6 +1,10 @@
1
1
  ## Change Log
2
2
 
3
- #### 3.28.4
3
+ #### 3.28.6
4
+
5
+ - fix calling stripData in with null / undefined
6
+
7
+ #### 3.28.5
4
8
 
5
9
  - implement new job scheduler
6
10
 
@@ -49,7 +49,7 @@ let DefaultHttpRequestHandler = class DefaultHttpRequestHandler extends Abstract
49
49
  });
50
50
  const response = await endpoint.controller[endpoint.name](...params);
51
51
  //-- validate response value against response dto
52
- if (endpoint.responseDto) {
52
+ if (endpoint.responseDto && response.value !== null && response.value !== undefined) {
53
53
  response.value = stripData(response.value, endpoint.responseDto);
54
54
  }
55
55
  return response;
@@ -26,6 +26,7 @@ export declare abstract class AbstractJobScheduler {
26
26
  protected abstract cancelJob(id: string): Promise<void>;
27
27
  protected abstract retryJob(job: AbstractJob, at: number): Promise<void>;
28
28
  protected abstract cleanupJob(id: string): Promise<void>;
29
+ protected afterJobRun(job: AbstractJob): Promise<void>;
29
30
  /**
30
31
  * Remove the scheduled job and prevent if from running in the future
31
32
  * @param id The job id returned from scheduleJobAt function
@@ -27,6 +27,11 @@ export class AbstractJobScheduler {
27
27
  await this.registerJob({ ...payload, id: jobId });
28
28
  return jobId;
29
29
  }
30
+ async afterJobRun(job) {
31
+ if (job.at) {
32
+ await this.cleanupJob(job.id).catch((err) => this.logger.error(`Failed to cleanup one time job ${job.id}`, err));
33
+ }
34
+ }
30
35
  /**
31
36
  * Remove the scheduled job and prevent if from running in the future
32
37
  * @param id The job id returned from scheduleJobAt function
@@ -65,7 +70,7 @@ export class AbstractJobScheduler {
65
70
  this.logger.debug(`Calling job handler for ${job.id}`);
66
71
  await jobHandler.handlerFn(job);
67
72
  this.logger.debug(`Job handler for ${job.id} completed`);
68
- await this.cleanupJob(job.id).catch((err) => this.logger.error(`Failed to cleanup job: ${job.id}`, err));
73
+ await this.afterJobRun(job);
69
74
  //-- job run success, update
70
75
  update.lastSuccessAt = Date.now();
71
76
  //-- reset retry count if this is cron job
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/server",
3
- "version": "3.28.4",
3
+ "version": "3.28.6",
4
4
  "description": "Claire server NodeJs framework written in Typescript.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",