From 4a7b3bcc3a224dc6ce58147bccc84798125d49ab Mon Sep 17 00:00:00 2001 From: AyrisAI Date: Thu, 14 May 2026 19:16:08 +0300 Subject: [PATCH] chore: simplify to plain JS worker.js and finalize install instructions --- .env | 2 + .env.example | 6 -- .gitignore | 4 - Dockerfile | 5 +- README.md | 36 ++++--- package-lock.json | 161 ------------------------------- package.json | 16 +++ tsconfig.json | 42 -------- apps/worker/main.ts => worker.js | 0 9 files changed, 37 insertions(+), 235 deletions(-) create mode 100644 .env delete mode 100644 .env.example delete mode 100644 .gitignore delete mode 100644 package-lock.json create mode 100644 package.json delete mode 100644 tsconfig.json rename apps/worker/main.ts => worker.js (100%) diff --git a/.env b/.env new file mode 100644 index 0000000..8276d80 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +NEXTJS_WEBHOOK_URL=https://webmail.ayris.tech/api/webhooks/mail-signal +WEBHOOK_SECRET=besiktasK1903* \ No newline at end of file diff --git a/.env.example b/.env.example deleted file mode 100644 index 8c84f66..0000000 --- a/.env.example +++ /dev/null @@ -1,6 +0,0 @@ -# Webhook Configuration -NEXTJS_WEBHOOK_URL=https://your-nextjs-app.com/api/webhooks/mail-signal -WEBHOOK_SECRET=besiktasK1903* - -# Redis (Optional, if used in other parts) -REDIS_URL=redis://localhost:6379 diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 896aacb..0000000 --- a/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules -.env -dist -*.log diff --git a/Dockerfile b/Dockerfile index 5ac764e..368eedc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,8 @@ RUN apk add --no-cache docker-cli WORKDIR /app COPY package*.json ./ -RUN npm install +RUN npm install --production COPY . . -# Run using the start script (tsx apps/worker/main.ts) -CMD ["npm", "start"] \ No newline at end of file +CMD ["npm", "start"] diff --git a/README.md b/README.md index a46f565..ef0efd9 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,40 @@ -# AyrisTech Worker (V10.3) +# AyrisTech Mail Worker (V10.3) -This worker monitors Mailcow vmail volumes and triggers Next.js webhooks when new mail arrives. +Mailcow Dovecot loglarını ve dosya sistemini izleyerek yeni gelen mailleri Next.js webhook'una ileten servis. -## Features -- Real-time filesystem monitoring with `chokidar` -- Automatic mail decoding via `doveadm` -- Next.js Webhook integration -- Secure secret-based authentication +## Kurulum -## Setup Instructions - -### 1. Configuration -Create a `.env` file in the root directory (copy from `.env.example` if available): +### 1. Dosyaları Hazırlayın +Proje dizinine gidin ve `.env` dosyasını düzenleyin: ```env -NEXTJS_WEBHOOK_URL=https://your-nextjs-app.com/api/webhooks/mail-signal -WEBHOOK_SECRET=your_secret_here +NEXTJS_WEBHOOK_URL=https://webmail.ayris.tech/api/webhooks/mail-signal +WEBHOOK_SECRET=besiktasK1903* ``` -### 2. Local Installation +### 2. Yerel Çalıştırma +Node.js (v18+) yüklü olduğundan emin olun: ```bash npm install npm start ``` -### 3. Docker Deployment -To run as a container, you must provide access to the Docker socket and the Mailcow volumes: +### 3. Docker ile Çalıştırma +En güvenli ve kolay yöntem Docker konteyneri olarak çalıştırmaktır: ```bash +# Resmi oluşturun docker build -t ayristech-worker . +# Konteyneri başlatın docker run -d \ --name ayristech-worker \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/_data/:/var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/_data/ \ --env-file .env \ + --restart unless-stopped \ ayristech-worker ``` -## Important Notes -- **Docker Socket**: The worker runs `docker exec` commands, so `/var/run/docker.sock` must be mounted. -- **Vmail Path**: The worker watches `/var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/_data/`. Ensure this volume exists and is mounted at the exact same path inside the container. +## Önemli Notlar +- **Docker Socket**: Servis `docker exec` komutu kullandığı için `/var/run/docker.sock` mount edilmelidir. +- **Vmail Volümü**: Mailcow'un mail dosyalarını sakladığı volüm `/var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/_data/` yoluna mount edilmelidir. diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index f6482c9..0000000 --- a/package-lock.json +++ /dev/null @@ -1,161 +0,0 @@ -{ - "name": "ayristech-worker", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "ayristech-worker", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "ioredis": "^5.10.1" - }, - "devDependencies": { - "@types/node": "^25.7.0", - "typescript": "^6.0.3" - } - }, - "node_modules/@ioredis/commands": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.5.1.tgz", - "integrity": "sha512-JH8ZL/ywcJyR9MmJ5BNqZllXNZQqQbnVZOqpPQqE1vHiFgAw4NHbvE0FOduNU8IX9babitBT46571OnPTT0Zcw==", - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "25.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.7.0.tgz", - "integrity": "sha512-z+pdZyxE+RTQE9AcboAZCb4otwcrvgHD+GlBpPgn0emDVt0ohrTMhAwlr2Wd9nZ+nihhYFxO2pThz3C5qSu2Eg==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~7.21.0" - } - }, - "node_modules/cluster-key-slot": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", - "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==", - "license": "Apache-2.0", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/denque": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", - "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", - "license": "Apache-2.0", - "engines": { - "node": ">=0.10" - } - }, - "node_modules/ioredis": { - "version": "5.10.1", - "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.10.1.tgz", - "integrity": "sha512-HuEDBTI70aYdx1v6U97SbNx9F1+svQKBDo30o0b9fw055LMepzpOOd0Ccg9Q6tbqmBSJaMuY0fB7yw9/vjBYCA==", - "license": "MIT", - "dependencies": { - "@ioredis/commands": "1.5.1", - "cluster-key-slot": "^1.1.0", - "debug": "^4.3.4", - "denque": "^2.1.0", - "lodash.defaults": "^4.2.0", - "lodash.isarguments": "^3.1.0", - "redis-errors": "^1.2.0", - "redis-parser": "^3.0.0", - "standard-as-callback": "^2.1.0" - }, - "engines": { - "node": ">=12.22.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/ioredis" - } - }, - "node_modules/lodash.defaults": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", - "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==", - "license": "MIT" - }, - "node_modules/lodash.isarguments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==", - "license": "MIT" - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/redis-errors": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", - "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==", - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/redis-parser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", - "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", - "license": "MIT", - "dependencies": { - "redis-errors": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/standard-as-callback": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", - "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==", - "license": "MIT" - }, - "node_modules/typescript": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", - "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/undici-types": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.21.0.tgz", - "integrity": "sha512-w9IMgQrz4O0YN1LtB7K5P63vhlIOvC7opSmouCJ+ZywlPAlO9gIkJ+otk6LvGpAs2wg4econaCz3TvQ9xPoyuQ==", - "dev": true, - "license": "MIT" - } - } -} diff --git a/package.json b/package.json new file mode 100644 index 0000000..52c6a05 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "ayristech-worker", + "version": "1.0.0", + "description": "AyrisTech Mailcow Worker", + "main": "worker.js", + "scripts": { + "start": "node worker.js", + "dev": "node --watch worker.js" + }, + "dependencies": { + "axios": "^1.16.1", + "chokidar": "^5.0.0", + "dotenv": "^17.4.2", + "ioredis": "^5.10.1" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index a46c4cf..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - // Visit https://aka.ms/tsconfig to read more about this file - "compilerOptions": { - // File Layout - "rootDir": "./", - "outDir": "./dist", - - // Environment Settings - // See also https://aka.ms/tsconfig/module - "module": "nodenext", - "target": "esnext", - "lib": ["esnext"], - "types": ["node"], - // and npm install -D @types/node - - // Other Outputs - "sourceMap": true, - "declaration": true, - "declarationMap": true, - - // Stricter Typechecking Options - "noUncheckedIndexedAccess": true, - "exactOptionalPropertyTypes": true, - - // Style Options - // "noImplicitReturns": true, - // "noImplicitOverride": true, - // "noUnusedLocals": true, - // "noUnusedParameters": true, - // "noFallthroughCasesInSwitch": true, - // "noPropertyAccessFromIndexSignature": true, - - // Recommended Options - "strict": true, - "jsx": "react-jsx", - "verbatimModuleSyntax": true, - "isolatedModules": true, - "noUncheckedSideEffectImports": true, - "moduleDetection": "force", - "skipLibCheck": true, - } -} diff --git a/apps/worker/main.ts b/worker.js similarity index 100% rename from apps/worker/main.ts rename to worker.js