imean-service-engine 1.0.0 → 1.1.0

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/dist/mod.cjs CHANGED
@@ -8,6 +8,7 @@ var fs = require('fs-extra');
8
8
  var hono = require('hono');
9
9
  var lruCache = require('lru-cache');
10
10
  var winston = require('winston');
11
+ var prettier = require('prettier');
11
12
  var api = require('@opentelemetry/api');
12
13
  var apiLogs = require('@opentelemetry/api-logs');
13
14
  var crypto2 = require('crypto');
@@ -20,6 +21,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
20
21
  var ejson3__default = /*#__PURE__*/_interopDefault(ejson3);
21
22
  var fs__default = /*#__PURE__*/_interopDefault(fs);
22
23
  var winston__default = /*#__PURE__*/_interopDefault(winston);
24
+ var prettier__default = /*#__PURE__*/_interopDefault(prettier);
23
25
  var crypto2__default = /*#__PURE__*/_interopDefault(crypto2);
24
26
  var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
25
27
 
@@ -220,11 +222,9 @@ var Scheduler = class {
220
222
  }
221
223
  }
222
224
  };
223
-
224
- // utils/format.ts
225
225
  async function formatCode(code) {
226
226
  try {
227
- return code;
227
+ return prettier__default.default.format(code, { parser: "typescript" });
228
228
  } catch {
229
229
  return code;
230
230
  }
@@ -432,7 +432,7 @@ var ActionHandler = class {
432
432
  const cacheKey = `${this.moduleName}.${this.actionName}.${requestHash}`;
433
433
  const cached = await this.microservice.cache.get(cacheKey);
434
434
  const now = Date.now();
435
- if (cached.value !== null && (!this.metadata.ttl || cached.value?.expireAt > now)) {
435
+ if (cached !== null && (!this.metadata.ttl || cached?.expireAt > now)) {
436
436
  this.microservice.updateMethodStats(
437
437
  this.moduleName,
438
438
  this.actionName,
@@ -440,7 +440,7 @@ var ActionHandler = class {
440
440
  true,
441
441
  true
442
442
  );
443
- return cached.value.data;
443
+ return cached.data;
444
444
  }
445
445
  }
446
446
  try {
@@ -497,10 +497,14 @@ var ActionHandler = class {
497
497
  if (this.metadata.cache && !this.microservice.options.disableCache) {
498
498
  const cacheKey = `${this.moduleName}.${this.actionName}.${requestHash}`;
499
499
  const now = Date.now();
500
- this.microservice.cache.set(cacheKey, {
501
- data: parsedResult,
502
- expireAt: this.metadata.ttl ? now + this.metadata.ttl : void 0
503
- });
500
+ this.microservice.cache.set(
501
+ cacheKey,
502
+ {
503
+ data: parsedResult,
504
+ expireAt: this.metadata.ttl ? now + this.metadata.ttl : void 0
505
+ },
506
+ { ttl: this.metadata.ttl }
507
+ );
504
508
  }
505
509
  this.microservice.updateMethodStats(
506
510
  this.moduleName,
package/dist/mod.js CHANGED
@@ -7,6 +7,7 @@ import fs from 'fs-extra';
7
7
  import { Hono } from 'hono';
8
8
  import { LRUCache } from 'lru-cache';
9
9
  import winston, { format } from 'winston';
10
+ import prettier from 'prettier';
10
11
  import { trace } from '@opentelemetry/api';
11
12
  import { logs } from '@opentelemetry/api-logs';
12
13
  import crypto2 from 'node:crypto';
@@ -212,11 +213,9 @@ var Scheduler = class {
212
213
  }
213
214
  }
214
215
  };
215
-
216
- // utils/format.ts
217
216
  async function formatCode(code) {
218
217
  try {
219
- return code;
218
+ return prettier.format(code, { parser: "typescript" });
220
219
  } catch {
221
220
  return code;
222
221
  }
@@ -424,7 +423,7 @@ var ActionHandler = class {
424
423
  const cacheKey = `${this.moduleName}.${this.actionName}.${requestHash}`;
425
424
  const cached = await this.microservice.cache.get(cacheKey);
426
425
  const now = Date.now();
427
- if (cached.value !== null && (!this.metadata.ttl || cached.value?.expireAt > now)) {
426
+ if (cached !== null && (!this.metadata.ttl || cached?.expireAt > now)) {
428
427
  this.microservice.updateMethodStats(
429
428
  this.moduleName,
430
429
  this.actionName,
@@ -432,7 +431,7 @@ var ActionHandler = class {
432
431
  true,
433
432
  true
434
433
  );
435
- return cached.value.data;
434
+ return cached.data;
436
435
  }
437
436
  }
438
437
  try {
@@ -489,10 +488,14 @@ var ActionHandler = class {
489
488
  if (this.metadata.cache && !this.microservice.options.disableCache) {
490
489
  const cacheKey = `${this.moduleName}.${this.actionName}.${requestHash}`;
491
490
  const now = Date.now();
492
- this.microservice.cache.set(cacheKey, {
493
- data: parsedResult,
494
- expireAt: this.metadata.ttl ? now + this.metadata.ttl : void 0
495
- });
491
+ this.microservice.cache.set(
492
+ cacheKey,
493
+ {
494
+ data: parsedResult,
495
+ expireAt: this.metadata.ttl ? now + this.metadata.ttl : void 0
496
+ },
497
+ { ttl: this.metadata.ttl }
498
+ );
496
499
  }
497
500
  this.microservice.updateMethodStats(
498
501
  this.moduleName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imean-service-engine",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "microservice engine",
5
5
  "keywords": [
6
6
  "microservice",
@@ -37,7 +37,7 @@
37
37
  "fmt": "deno fmt",
38
38
  "test": "vitest",
39
39
  "coverage": "vitest --coverage",
40
- "prepublishOnly": "npm run build"
40
+ "prepublishOnly": "npm run build && npm run test"
41
41
  },
42
42
  "dependencies": {
43
43
  "@hono/node-server": "^1.13.7",
@@ -50,6 +50,7 @@
50
50
  "fs-extra": "^11.3.0",
51
51
  "hono": "^4.6.17",
52
52
  "lru-cache": "^11.0.2",
53
+ "prettier": "^3.4.2",
53
54
  "winston": "^3.17.0",
54
55
  "zod": "^3.24.1"
55
56
  },
@@ -60,7 +61,7 @@
60
61
  "@types/ejson": "^2.2.2",
61
62
  "@types/fs-extra": "^11.0.4",
62
63
  "@types/node": "^20.0.0",
63
- "imean-service-client": "^1.4.1",
64
+ "imean-service-client": "^1.4.4",
64
65
  "tslib": "^2.8.1",
65
66
  "tsup": "^8.0.1",
66
67
  "tsx": "^4.19.2",
@@ -69,6 +70,6 @@
69
70
  "vitest": "^3.0.3"
70
71
  },
71
72
  "engines": {
72
- "node": ">=23"
73
+ "node": ">=20"
73
74
  }
74
75
  }