@senhainfo/shared-utils 1.2.0 → 1.2.2
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/lib/windows-service.d.ts
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type WindowsServiceOptions = ServiceConfig & {
|
|
3
|
-
logOnAs?: User;
|
|
4
|
-
};
|
|
1
|
+
import { Service, ServiceConfig } from "node-windows";
|
|
5
2
|
export declare class WindowsService {
|
|
6
3
|
private options;
|
|
7
|
-
|
|
4
|
+
service: Service;
|
|
8
5
|
/**
|
|
9
6
|
* Constructor
|
|
10
|
-
* @param {
|
|
7
|
+
* @param {ServiceConfig} config - Configuration for the Windows service
|
|
11
8
|
*
|
|
12
9
|
* @default { name: "Senha API - Service", script: "dist/server.js" }
|
|
13
10
|
*
|
|
14
11
|
* @example
|
|
15
12
|
* const service = new WindowsService({ name: "My Service", script: "path/to/service" });
|
|
16
13
|
*/
|
|
17
|
-
constructor(
|
|
18
|
-
install(): void;
|
|
19
|
-
uninstall(): void;
|
|
20
|
-
start(): void;
|
|
21
|
-
stop(): void;
|
|
22
|
-
restart(): void;
|
|
14
|
+
constructor(config?: ServiceConfig);
|
|
23
15
|
}
|
|
24
|
-
export {};
|
|
25
16
|
//# sourceMappingURL=windows-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows-service.d.ts","sourceRoot":"","sources":["../src/windows-service.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"windows-service.d.ts","sourceRoot":"","sources":["../src/windows-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGtD,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAIb;IAEK,OAAO,EAAE,OAAO,CAA6B;IAEpD;;;;;;;;OAQG;gBACS,MAAM,CAAC,EAAE,aAAa;CAuBnC"}
|
package/lib/windows-service.js
CHANGED
|
@@ -9,59 +9,41 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
9
9
|
class WindowsService {
|
|
10
10
|
/**
|
|
11
11
|
* Constructor
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {ServiceConfig} config - Configuration for the Windows service
|
|
13
13
|
*
|
|
14
14
|
* @default { name: "Senha API - Service", script: "dist/server.js" }
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* const service = new WindowsService({ name: "My Service", script: "path/to/service" });
|
|
18
18
|
*/
|
|
19
|
-
constructor(
|
|
20
|
-
this.
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.options = {
|
|
21
21
|
name: "Senha API - Service",
|
|
22
22
|
description: "Senha API - Service",
|
|
23
23
|
script: node_path_1.default.join("dist", "server.js"),
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
if (options) {
|
|
30
|
-
Object.assign(this.options, options);
|
|
24
|
+
};
|
|
25
|
+
this.service = new node_windows_1.Service(this.options);
|
|
26
|
+
if (config) {
|
|
27
|
+
Object.assign(this.options, config);
|
|
31
28
|
}
|
|
32
29
|
this.service
|
|
33
30
|
.on("install", () => {
|
|
34
31
|
this.service.start();
|
|
35
|
-
console.log(
|
|
32
|
+
console.log(`Service "${this.options.name}" installed`);
|
|
36
33
|
})
|
|
37
34
|
.on("alreadyinstalled", () => {
|
|
38
|
-
console.log(
|
|
35
|
+
console.log(`Service "${this.options.name}" is already installed`);
|
|
39
36
|
})
|
|
40
37
|
.on("uninstall", () => {
|
|
41
|
-
console.log(
|
|
38
|
+
console.log(`Service "${this.options.name}" uninstalled`);
|
|
42
39
|
})
|
|
43
40
|
.on("start", () => {
|
|
44
|
-
console.log(
|
|
41
|
+
console.log("Service started");
|
|
45
42
|
})
|
|
46
43
|
.on("stop", () => {
|
|
47
|
-
console.log(
|
|
44
|
+
console.log("Service stopped");
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
|
-
install() {
|
|
51
|
-
this.service.install();
|
|
52
|
-
}
|
|
53
|
-
uninstall() {
|
|
54
|
-
this.service.uninstall();
|
|
55
|
-
}
|
|
56
|
-
start() {
|
|
57
|
-
this.service.start();
|
|
58
|
-
}
|
|
59
|
-
stop() {
|
|
60
|
-
this.service.stop();
|
|
61
|
-
}
|
|
62
|
-
restart() {
|
|
63
|
-
this.service.restart();
|
|
64
|
-
}
|
|
65
47
|
}
|
|
66
48
|
exports.WindowsService = WindowsService;
|
|
67
49
|
//# sourceMappingURL=windows-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows-service.js","sourceRoot":"","sources":["../src/windows-service.ts"],"names":[],"mappings":";;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"windows-service.js","sourceRoot":"","sources":["../src/windows-service.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAsD;AACtD,0DAA6B;AAE7B,MAAa,cAAc;IASzB;;;;;;;;OAQG;IACH,YAAY,MAAsB;QAjB1B,YAAO,GAAkB;YAC/B,IAAI,EAAE,qBAAqB;YAC3B,WAAW,EAAE,qBAAqB;YAClC,MAAM,EAAE,mBAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC;SACvC,CAAC;QAEK,YAAO,GAAY,IAAI,sBAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAYlD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,OAAO;aACT,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAClB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,IAAI,aAAa,CAAC,CAAC;QAC1D,CAAC,CAAC;aACD,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,IAAI,wBAAwB,CAAC,CAAC;QACrE,CAAC,CAAC;aACD,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,CAAC;QAC5D,CAAC,CAAC;aACD,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAChB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC,CAAC;aACD,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACf,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACP,CAAC;CACF;AAzCD,wCAyCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senhainfo/shared-utils",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"repository": "https://github.com/senha-info/senha-shared-utils.git",
|
|
5
5
|
"author": "Bruno Gaspar <bruninhoogaspar@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^22.14.0",
|
|
27
|
-
"@types/node-windows": "^0.1.6",
|
|
28
27
|
"tsx": "^4.19.3",
|
|
29
28
|
"typescript": "^5.8.2"
|
|
30
29
|
},
|
|
31
30
|
"dependencies": {
|
|
32
31
|
"axios": "^1.8.4",
|
|
33
32
|
"date-fns": "^4.1.0",
|
|
34
|
-
"node-windows": "^1.0.0-beta.8"
|
|
33
|
+
"node-windows": "^1.0.0-beta.8",
|
|
34
|
+
"@types/node-windows": "^0.1.6"
|
|
35
35
|
}
|
|
36
36
|
}
|