@qelos/api-kit 3.4.1 → 3.5.4

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.
@@ -1,2 +1,2 @@
1
- declare let shutdown: () => never;
1
+ declare let shutdown: (_code?: number) => never;
2
2
  export default shutdown;
package/dist/shutdown.js CHANGED
@@ -1,20 +1,36 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- let shutdown = () => {
6
+ const node_fs_1 = __importDefault(require("node:fs"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ let shutdown = (_code) => {
4
9
  process.exit();
5
10
  };
6
11
  if (process.env.NODE_ENV !== 'production') {
7
- shutdown = () => {
8
- const fs = require('fs');
12
+ console.log('trying to require tmp file...');
13
+ try {
9
14
  const cwd = process.cwd();
10
- fs.readdirSync(cwd).forEach(filename => {
11
- if (filename.includes('index.') || filename.includes('server.')) {
12
- const filePath = require('path').join(cwd, filename);
13
- fs.writeFileSync(filePath, fs.readFileSync(filePath));
15
+ const tempFolder = node_path_1.default.join(cwd, 'tmp');
16
+ const tempFile = node_path_1.default.join(tempFolder, 'tmp.js');
17
+ if (!node_fs_1.default.existsSync(tempFolder)) {
18
+ node_fs_1.default.mkdirSync(tempFolder);
19
+ }
20
+ if (!node_fs_1.default.existsSync(tempFile)) {
21
+ node_fs_1.default.writeFileSync(tempFile, '');
22
+ }
23
+ require(tempFile);
24
+ shutdown = (code) => {
25
+ if (code?.toString() === '1') {
26
+ node_fs_1.default.writeFileSync(tempFile, '');
14
27
  }
15
- });
16
- process.exit();
17
- };
28
+ process.exit();
29
+ };
30
+ }
31
+ catch (err) {
32
+ console.error(err);
33
+ }
18
34
  process.on('exit', shutdown);
19
35
  }
20
36
  globalThis.shutdown = shutdown;
@@ -1 +1 @@
1
- {"version":3,"file":"shutdown.js","source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AC1C,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;IAC5C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1B,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,iBAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAC1B,CAAC;QACD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,iBAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,CAAC,QAAQ,CAAC,CAAA;QAEjB,QAAQ,GAAG,CAAC,IAAsB,EAAE,EAAE;YACpC,IAAI,IAAI,EAAE,QAAQ,EAAE,KAAK,GAAG,EAAE,CAAC;gBAC7B,iBAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YAChC,CAAC;YACD,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;IAED,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAED,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAE/B,kBAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qelos/api-kit",
3
- "version": "3.4.1",
3
+ "version": "3.5.4",
4
4
  "description": "API-Kit package to help with qelos infrastructure and reuse capabilities across services",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "express": "^4.19.2",
19
19
  "morgan": "^1.10.0"
20
20
  },
21
- "gitHead": "d6e98230be662ec343c5b09b9115d21a9358e682",
21
+ "gitHead": "a952292a7de503674aac40136fb448dc6350e55a",
22
22
  "devDependencies": {
23
23
  "@types/node": "^20.12.8",
24
24
  "typescript": "^5.4.5"
package/src/shutdown.ts CHANGED
@@ -1,18 +1,32 @@
1
- let shutdown = () => {
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ let shutdown = (_code?: number) => {
2
5
  process.exit();
3
6
  };
4
7
 
5
8
  if (process.env.NODE_ENV !== 'production') {
6
- shutdown = () => {
7
- const fs = require('fs');
9
+ console.log('trying to require tmp file...')
10
+ try {
8
11
  const cwd = process.cwd();
9
- fs.readdirSync(cwd).forEach(filename => {
10
- if (filename.includes('index.') || filename.includes('server.')) {
11
- const filePath = require('path').join(cwd, filename);
12
- fs.writeFileSync(filePath, fs.readFileSync(filePath))
12
+ const tempFolder = path.join(cwd, 'tmp');
13
+ const tempFile = path.join(tempFolder, 'tmp.js');
14
+ if (!fs.existsSync(tempFolder)) {
15
+ fs.mkdirSync(tempFolder)
16
+ }
17
+ if (!fs.existsSync(tempFile)) {
18
+ fs.writeFileSync(tempFile, '');
19
+ }
20
+ require(tempFile)
21
+
22
+ shutdown = (code?: number | string) => {
23
+ if (code?.toString() === '1') {
24
+ fs.writeFileSync(tempFile, '')
13
25
  }
14
- })
15
- process.exit();
26
+ process.exit();
27
+ }
28
+ } catch (err) {
29
+ console.error(err)
16
30
  }
17
31
 
18
32
  process.on('exit', shutdown);
package/CONTRIBUTING.md DELETED
@@ -1,7 +0,0 @@
1
- # Contribute to Greenpress api-kit
2
-
3
- ## Greenpress [Contribute Guide](https://docs.greenpress.info/guide/contribute/getting-started.html)
4
-
5
- ## Greenpress [Installation Guide](https://docs.greenpress.info/guide/getting-started.html)
6
-
7
- ## [Open Issues](https://github.com/greenpress/api-kit/issues)