@wisemen/app-container 3.0.1 → 4.0.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.
Files changed (38) hide show
  1. package/LICENSE.md +59 -0
  2. package/dist/express/express.d.ts +18 -0
  3. package/dist/express/express.js +103 -0
  4. package/dist/express/express.js.map +1 -0
  5. package/dist/express/index.d.ts +3 -0
  6. package/dist/express/index.js +4 -0
  7. package/dist/express/index.js.map +1 -0
  8. package/dist/{containers → express}/job.d.ts +2 -2
  9. package/dist/express/job.js +9 -0
  10. package/dist/express/job.js.map +1 -0
  11. package/dist/express/worker.d.ts +3 -0
  12. package/dist/express/worker.js +4 -0
  13. package/dist/express/worker.js.map +1 -0
  14. package/dist/{containers/default.d.ts → fastify/fastify.d.ts} +2 -2
  15. package/dist/{containers/default.js → fastify/fastify.js} +5 -6
  16. package/dist/fastify/fastify.js.map +1 -0
  17. package/dist/fastify/index.d.ts +3 -0
  18. package/dist/fastify/index.js +4 -0
  19. package/dist/fastify/index.js.map +1 -0
  20. package/dist/fastify/job.d.ts +6 -0
  21. package/dist/fastify/job.js +9 -0
  22. package/dist/fastify/job.js.map +1 -0
  23. package/dist/fastify/worker.d.ts +3 -0
  24. package/dist/fastify/worker.js +4 -0
  25. package/dist/fastify/worker.js.map +1 -0
  26. package/package.json +57 -27
  27. package/dist/containers/api.d.ts +0 -3
  28. package/dist/containers/api.js +0 -4
  29. package/dist/containers/api.js.map +0 -1
  30. package/dist/containers/default.js.map +0 -1
  31. package/dist/containers/job.js +0 -9
  32. package/dist/containers/job.js.map +0 -1
  33. package/dist/containers/worker.d.ts +0 -3
  34. package/dist/containers/worker.js +0 -4
  35. package/dist/containers/worker.js.map +0 -1
  36. package/dist/index.d.ts +0 -3
  37. package/dist/index.js +0 -4
  38. package/dist/index.js.map +0 -1
package/LICENSE.md ADDED
@@ -0,0 +1,59 @@
1
+ # PolyForm Strict License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/strict/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software.
12
+
13
+ ## Patent License
14
+
15
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
16
+
17
+ ## Noncommercial Purposes
18
+
19
+ Any noncommercial purpose is a permitted purpose.
20
+
21
+ ## Personal Uses
22
+
23
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
24
+
25
+ ## Noncommercial Organizations
26
+
27
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
28
+
29
+ ## Fair Use
30
+
31
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
32
+
33
+ ## No Other Rights
34
+
35
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
36
+
37
+ ## Patent Defense
38
+
39
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
40
+
41
+ ## Violations
42
+
43
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
44
+
45
+ ## No Liability
46
+
47
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
48
+
49
+ ## Definitions
50
+
51
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
52
+
53
+ **You** refers to the individual or entity agreeing to these terms.
54
+
55
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
56
+
57
+ **Your licenses** are all the licenses granted to you for the software under these terms.
58
+
59
+ **Use** means anything you do with the software requiring one of your licenses.
@@ -0,0 +1,18 @@
1
+ import type { INestApplicationContext } from '@nestjs/common';
2
+ import { ExpressAdapter } from '@nestjs/platform-express';
3
+ export declare abstract class ExpressContainer {
4
+ private readonly app;
5
+ private readonly server;
6
+ private state;
7
+ protected nest?: INestApplicationContext;
8
+ abstract bootstrap(app: ExpressAdapter): Promise<INestApplicationContext>;
9
+ constructor();
10
+ private _init;
11
+ protected init(): Promise<void>;
12
+ protected close(): Promise<void>;
13
+ private enableShutdownHooks;
14
+ private enableProbes;
15
+ private liveness;
16
+ private readiness;
17
+ private version;
18
+ }
@@ -0,0 +1,103 @@
1
+ import express from 'express';
2
+ import { ExpressAdapter } from '@nestjs/platform-express';
3
+ const port = process.env.PORT ?? 3000;
4
+ export class ExpressContainer {
5
+ app;
6
+ server;
7
+ state;
8
+ nest;
9
+ constructor() {
10
+ this.state = 'starting';
11
+ this.app = express();
12
+ this.server = this.app.listen(port, () => {
13
+ console.log('server started');
14
+ });
15
+ this.enableShutdownHooks();
16
+ this.enableProbes();
17
+ void this._init();
18
+ }
19
+ async _init() {
20
+ try {
21
+ await this.init();
22
+ }
23
+ catch (e) {
24
+ await this.close();
25
+ console.log(e);
26
+ process.exit(1);
27
+ }
28
+ }
29
+ async init() {
30
+ const adapter = new ExpressAdapter(this.app);
31
+ adapter.setHttpServer(this.server);
32
+ this.nest = await this.bootstrap(adapter);
33
+ await this.nest.init();
34
+ this.state = 'ready';
35
+ }
36
+ async close() {
37
+ if (this.state === 'shutdown') {
38
+ return;
39
+ }
40
+ this.state = 'shutdown';
41
+ try {
42
+ await new Promise((resolve, reject) => {
43
+ this.server.close((err) => {
44
+ if (err)
45
+ reject(err);
46
+ else
47
+ resolve();
48
+ });
49
+ });
50
+ await this.nest?.close();
51
+ console.log('application closed');
52
+ }
53
+ catch (e) {
54
+ console.error('error shutting down', e);
55
+ process.exit(1);
56
+ }
57
+ }
58
+ enableShutdownHooks() {
59
+ process.on('SIGTERM', () => void this.close());
60
+ process.on('SIGINT', () => void this.close());
61
+ process.on('SIGUSR2', () => void this.close());
62
+ process.on('SIGHUP', () => void this.close());
63
+ process.on('exit', () => void this.close());
64
+ }
65
+ enableProbes() {
66
+ this.app.get('/', (_, res) => {
67
+ this.version(res);
68
+ });
69
+ this.app.get('/health', (_, res) => {
70
+ this.liveness(res);
71
+ });
72
+ this.app.get('/ready', (_, res) => {
73
+ this.readiness(res);
74
+ });
75
+ }
76
+ liveness(res) {
77
+ res.writeHead(200, { 'Content-Type': 'text/plain' });
78
+ res.write('OK');
79
+ res.end();
80
+ }
81
+ readiness(res) {
82
+ if (this.state === 'ready') {
83
+ res.writeHead(200, { 'Content-Type': 'text/plain' });
84
+ res.write('OK');
85
+ }
86
+ else {
87
+ res.writeHead(500, { 'Content-Type': 'text/plain' });
88
+ res.write('not OK');
89
+ }
90
+ res.end();
91
+ }
92
+ version(res) {
93
+ res.writeHead(200, { 'Content-Type': 'application/json' });
94
+ res.write(JSON.stringify({
95
+ env: process.env.NODE_ENV,
96
+ commit: process.env.COMMIT,
97
+ build: process.env.BUILD_NUMBER,
98
+ version: process.env.VERSION
99
+ }));
100
+ res.end();
101
+ }
102
+ }
103
+ //# sourceMappingURL=express.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express.js","sourceRoot":"","sources":["../../lib/containers/express/express.ts"],"names":[],"mappings":"AACA,OAAO,OAAyB,MAAM,SAAS,CAAA;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAA;A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,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;YACzB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;YAC1B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;YAC/B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;SAC7B,CAAC,CAAC,CAAA;QACH,GAAG,CAAC,GAAG,EAAE,CAAA;IACX,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export * from './express.js';
2
+ export * from './job.js';
3
+ export * from './worker.js';
@@ -0,0 +1,4 @@
1
+ export * from './express.js';
2
+ export * from './job.js';
3
+ export * from './worker.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/containers/express/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import type { INestApplicationContext } from '@nestjs/common';
2
- import { ProbedContainer } from './default.js';
3
- export declare abstract class JobContainer extends ProbedContainer {
2
+ import { ExpressContainer } from './express.js';
3
+ export declare abstract class JobContainer extends ExpressContainer {
4
4
  abstract execute(nest: INestApplicationContext): Promise<void>;
5
5
  protected init(): Promise<void>;
6
6
  }
@@ -0,0 +1,9 @@
1
+ import { ExpressContainer } from './express.js';
2
+ export class JobContainer extends ExpressContainer {
3
+ async init() {
4
+ await super.init();
5
+ await this.execute(this.nest);
6
+ await this.close();
7
+ }
8
+ }
9
+ //# sourceMappingURL=job.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.js","sourceRoot":"","sources":["../../lib/containers/express/job.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,OAAgB,YAAa,SAAQ,gBAAgB;IAG/C,KAAK,CAAC,IAAI;QAClB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAElB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAK,CAAC,CAAA;QAE9B,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import { ExpressContainer } from './express.js';
2
+ export declare abstract class WorkerContainer extends ExpressContainer {
3
+ }
@@ -0,0 +1,4 @@
1
+ import { ExpressContainer } from './express.js';
2
+ export class WorkerContainer extends ExpressContainer {
3
+ }
4
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../lib/containers/express/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,OAAgB,eAAgB,SAAQ,gBAAgB;CAAG"}
@@ -1,7 +1,7 @@
1
1
  import type { INestApplicationContext } from '@nestjs/common';
2
2
  import { FastifyAdapter } from '@nestjs/platform-fastify';
3
- import { type FastifyServerOptions } from 'fastify';
4
- export declare abstract class ProbedContainer {
3
+ import type { FastifyServerOptions } from 'fastify';
4
+ export declare abstract class FastifyContainer {
5
5
  private adapter?;
6
6
  private state;
7
7
  private server;
@@ -1,7 +1,6 @@
1
1
  import { FastifyAdapter } from '@nestjs/platform-fastify';
2
- import { fastify } from 'fastify';
3
2
  const port = Number(process.env.PORT) || 3000;
4
- export class ProbedContainer {
3
+ export class FastifyContainer {
5
4
  adapter;
6
5
  state;
7
6
  server;
@@ -25,13 +24,13 @@ export class ProbedContainer {
25
24
  }
26
25
  }
27
26
  async init() {
28
- this.server = fastify(this.getFastifyOptions());
29
- this.adapter = new FastifyAdapter(this.server);
27
+ this.adapter = new FastifyAdapter(this.getFastifyOptions());
28
+ this.server = this.adapter.getInstance();
30
29
  this.enableProbes();
31
30
  this.nest = await this.bootstrap(this.adapter);
32
31
  await this.nest.init();
33
32
  await this.server.listen({ port, host: '0.0.0.0' });
34
- console.log('Server listening on port', port);
33
+ console.log('server started');
35
34
  this.state = 'ready';
36
35
  }
37
36
  async close() {
@@ -88,4 +87,4 @@ export class ProbedContainer {
88
87
  });
89
88
  }
90
89
  }
91
- //# sourceMappingURL=default.js.map
90
+ //# sourceMappingURL=fastify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fastify.js","sourceRoot":"","sources":["../../lib/containers/fastify/fastify.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;AAI7C,MAAM,OAAgB,gBAAgB;IAC5B,OAAO,CAAiB;IACxB,KAAK,CAAO;IACZ,MAAM,CAAiB;IAErB,IAAI,CAA0B;IAC9B,iBAAiB;QACzB,OAAO,EAAE,CAAA;IACX,CAAC;IAID;QACE,IAAI,CAAC,KAAK,GAAG,UAAU,CAAA;QAEvB,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAE1B,KAAK,IAAI,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC;IAEO,KAAK,CAAC,KAAK;QACjB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;QACnB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;YAElB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAEd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;IAES,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;QAE3D,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAA;QAExC,IAAI,CAAC,YAAY,EAAE,CAAA;QAEnB,IAAI,CAAC,IAAI,GAAG,MAAM,I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B,CAAC,CAAC,IAAI,CAAC;YAC5C,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;YACzB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;YAC1B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;YAC/B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;SAC7B,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export * from './fastify.js';
2
+ export * from './job.js';
3
+ export * from './worker.js';
@@ -0,0 +1,4 @@
1
+ export * from './fastify.js';
2
+ export * from './job.js';
3
+ export * from './worker.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/containers/fastify/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { INestApplicationContext } from '@nestjs/common';
2
+ import { FastifyContainer } from './fastify.js';
3
+ export declare abstract class JobContainer extends FastifyContainer {
4
+ abstract execute(nest: INestApplicationContext): Promise<void>;
5
+ protected init(): Promise<void>;
6
+ }
@@ -0,0 +1,9 @@
1
+ import { FastifyContainer } from './fastify.js';
2
+ export class JobContainer extends FastifyContainer {
3
+ async init() {
4
+ await super.init();
5
+ await this.execute(this.nest);
6
+ await this.close();
7
+ }
8
+ }
9
+ //# sourceMappingURL=job.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.js","sourceRoot":"","sources":["../../lib/containers/fastify/job.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,OAAgB,YAAa,SAAQ,gBAAgB;IAG/C,KAAK,CAAC,IAAI;QAClB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAElB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAK,CAAC,CAAA;QAE9B,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import { FastifyContainer } from './fastify.js';
2
+ export declare abstract class WorkerContainer extends FastifyContainer {
3
+ }
@@ -0,0 +1,4 @@
1
+ import { FastifyContainer } from './fastify.js';
2
+ export class WorkerContainer extends FastifyContainer {
3
+ }
4
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../lib/containers/fastify/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,OAAgB,eAAgB,SAAQ,gBAAgB;CAAG"}
package/package.json CHANGED
@@ -1,48 +1,78 @@
1
1
  {
2
2
  "name": "@wisemen/app-container",
3
- "version": "3.0.1",
3
+ "version": "4.0.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "A package for a nest app container in kubernetes",
5
8
  "directories": {
6
9
  "example": "examples"
7
10
  },
8
- "main": "./dist/index.js",
9
- "types": "./dist/index.d.ts",
10
11
  "type": "module",
12
+ "exports": {
13
+ "./express": {
14
+ "types": "./dist/express/index.d.ts",
15
+ "import": "./dist/express/index.js"
16
+ },
17
+ "./fastify": {
18
+ "types": "./dist/fastify/index.d.ts",
19
+ "import": "./dist/fastify/index.js"
20
+ }
21
+ },
11
22
  "files": [
12
23
  "dist/"
13
24
  ],
14
- "scripts": {
15
- "lint": "eslint lib",
16
- "prebuild": "rm -rf ./dist",
17
- "clean": "rm -r ./dist",
18
- "build": "tsc",
19
- "pretest": "npm run clean && npm run build",
20
- "test": "node --test",
21
- "prerelease": "npm run build",
22
- "release": "pnpx release-it"
25
+ "devDependencies": {
26
+ "@nestjs/common": "11.1.17",
27
+ "@nestjs/core": "11.1.17",
28
+ "@nestjs/platform-fastify": "11.1.17",
29
+ "@types/express": "5.0.6",
30
+ "@types/node": "25.3.0",
31
+ "eslint": "9.39.4",
32
+ "fastify": ">=5.8.4",
33
+ "typescript": ">=4.8.4 <=5.9.3",
34
+ "@wisemen/eslint-config-nestjs": "0.2.13"
23
35
  },
24
- "dependencies": {
25
- "fastify": "5.7.4"
36
+ "peerDependencies": {
37
+ "@nestjs/common": ">=11.1.17",
38
+ "@nestjs/platform-express": ">=11.1.17",
39
+ "@nestjs/platform-fastify": ">=11.1.17",
40
+ "express": ">=5.2.1",
41
+ "fastify": ">=5.8.2"
26
42
  },
27
- "devDependencies": {
28
- "@nestjs/common": "^11.1.13",
29
- "@nestjs/core": "^11.1.13",
30
- "@nestjs/platform-fastify": "^11.1.13",
31
- "@types/express": "^5.0.6",
32
- "@types/node": "^25.2.1",
33
- "@typescript-eslint/eslint-plugin": "^8.54.0",
34
- "@wisemen/eslint-config-nestjs": "^0.2.8",
35
- "eslint": "^9.39.2",
36
- "typescript": "^5.9.3"
43
+ "peerDependenciesMeta": {
44
+ "@nestjs/platform-express": {
45
+ "optional": true
46
+ },
47
+ "@nestjs/platform-fastify": {
48
+ "optional": true
49
+ },
50
+ "express": {
51
+ "optional": true
52
+ },
53
+ "fastify": {
54
+ "optional": true
55
+ }
37
56
  },
38
57
  "author": "Joren Vandeweyer",
39
58
  "license": "ISC",
40
59
  "repository": {
41
60
  "type": "git",
42
- "url": "git@github.com:wisemen-digital/node-core.git"
61
+ "url": "https://github.com/wisemen-digital/wisemen-core",
62
+ "directory": "packages/app-container"
43
63
  },
44
64
  "bugs": {
45
65
  "url": "https://github.com/wisemen-digital/node-core/issues"
46
66
  },
47
- "homepage": "https://github.com/wisemen-digital/node-core/packages/app-container"
48
- }
67
+ "homepage": "https://github.com/wisemen-digital/node-core/packages/app-container",
68
+ "scripts": {
69
+ "lint": "eslint lib",
70
+ "prebuild": "rm -rf ./dist",
71
+ "clean": "rm -rf ./dist",
72
+ "build": "tsc",
73
+ "pretest": "npm run clean && npm run build",
74
+ "test": "node --test",
75
+ "prerelease": "npm run build",
76
+ "release": "pnpx release-it"
77
+ }
78
+ }
@@ -1,3 +0,0 @@
1
- import { ProbedContainer } from './default.js';
2
- export declare abstract class ApiContainer extends ProbedContainer {
3
- }
@@ -1,4 +0,0 @@
1
- import { ProbedContainer } from './default.js';
2
- export class ApiContainer extends ProbedContainer {
3
- }
4
- //# sourceMappingURL=api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../lib/containers/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,OAAgB,YAAa,SAAQ,eAAe;CAAG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../../lib/containers/default.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,OAAO,EAAsF,MAAM,SAAS,CAAA;AAErH,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;AAI7C,MAAM,OAAgB,eAAe;IAC3B,OAAO,CAAiB;IACxB,KAAK,CAAO;IACZ,MAAM,CAAiB;IAErB,IAAI,CAA0B;IAC9B,iBAAiB;QACzB,OAAO,EAAE,CAAA;IACX,CAAC;IAID;QACE,IAAI,CAAC,KAAK,GAAG,UAAU,CAAA;QAEvB,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAE1B,KAAK,IAAI,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC;IAEO,KAAK,CAAC,KAAK;QACjB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;QACnB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;YAElB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAEd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB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AAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/C,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACnD,CAAC;IACH,CAAC;IAEO,OAAO,CAAE,GAAiB;QAChC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC;YAC5C,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;YACzB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;YAC1B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;YAC/B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;SAC7B,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -1,9 +0,0 @@
1
- import { ProbedContainer } from './default.js';
2
- export class JobContainer extends ProbedContainer {
3
- async init() {
4
- await super.init();
5
- await this.execute(this.nest);
6
- await this.close();
7
- }
8
- }
9
- //# sourceMappingURL=job.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"job.js","sourceRoot":"","sources":["../../lib/containers/job.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,OAAgB,YAAa,SAAQ,eAAe;IAG9C,KAAK,CAAC,IAAI;QAClB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAElB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAK,CAAC,CAAA;QAE9B,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF"}
@@ -1,3 +0,0 @@
1
- import { ProbedContainer } from './default.js';
2
- export declare abstract class WorkerContainer extends ProbedContainer {
3
- }
@@ -1,4 +0,0 @@
1
- import { ProbedContainer } from './default.js';
2
- export class WorkerContainer extends ProbedContainer {
3
- }
4
- //# sourceMappingURL=worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../lib/containers/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,OAAgB,eAAgB,SAAQ,eAAe;CAAG"}
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './containers/api.js';
2
- export * from './containers/job.js';
3
- export * from './containers/worker.js';
package/dist/index.js DELETED
@@ -1,4 +0,0 @@
1
- export * from './containers/api.js';
2
- export * from './containers/job.js';
3
- export * from './containers/worker.js';
4
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}