diff --git a/package.json b/package.json index 5c182838..09df55a4 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "mongoose": "^6.10.5", "node-cache": "^5.1.2", "node-mime-types": "^1.1.0", + "node-windows": "^1.0.0-beta.8", "pino": "^8.11.0", "proxy-agent": "^6.2.1", "qrcode": "^1.5.1", @@ -81,6 +82,7 @@ "@types/js-yaml": "^4.0.5", "@types/jsonwebtoken": "^8.5.9", "@types/node": "^18.15.11", + "@types/node-windows": "^0.1.2", "@types/qrcode": "^1.5.0", "@types/qrcode-terminal": "^0.12.0", "@types/uuid": "^8.3.4", diff --git a/src/install-evolution-api-ws.ts b/src/install-evolution-api-ws.ts new file mode 100644 index 00000000..1faadbf9 --- /dev/null +++ b/src/install-evolution-api-ws.ts @@ -0,0 +1,15 @@ +import nodeWindows from 'node-windows'; +import path from 'path'; + +const svc = new nodeWindows.Service({ + name: 'EvolutionAPIServer', + description: + 'WhatsApp-Api-NodeJs - This project is based on the CodeChat. The original project is an implementation of Baileys', + script: path.join(__dirname, 'main.js'), +}); + +svc.on('install', () => { + svc.start(); +}); + +svc.install(); diff --git a/src/uninstall-evolution-api-ws.ts b/src/uninstall-evolution-api-ws.ts new file mode 100644 index 00000000..4311f503 --- /dev/null +++ b/src/uninstall-evolution-api-ws.ts @@ -0,0 +1,16 @@ +import nodeWindows from 'node-windows'; +import path from 'path'; + +const svc = new nodeWindows.Service({ + name: 'EvolutionAPIServer', + description: + 'WhatsApp-Api-NodeJs - This project is based on the CodeChat. The original project is an implementation of Baileys', + script: path.join(__dirname, 'main.js'), +}); + +svc.on('uninstall', () => { + console.log('Uninstall complete.'); + console.log('The service exists: ', svc.exists); +}); + +svc.uninstall();