chore: simplify to plain JS worker.js and finalize install instructions

This commit is contained in:
AyrisAI
2026-05-14 19:16:08 +03:00
parent 06789a25af
commit 4a7b3bcc3a
9 changed files with 37 additions and 235 deletions

2
.env Normal file
View File

@@ -0,0 +1,2 @@
NEXTJS_WEBHOOK_URL=https://webmail.ayris.tech/api/webhooks/mail-signal
WEBHOOK_SECRET=besiktasK1903*

View File

@@ -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

4
.gitignore vendored
View File

@@ -1,4 +0,0 @@
node_modules
.env
dist
*.log

View File

@@ -7,9 +7,8 @@ RUN apk add --no-cache docker-cli
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install --production
COPY . . COPY . .
# Run using the start script (tsx apps/worker/main.ts)
CMD ["npm", "start"] CMD ["npm", "start"]

View File

@@ -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 ## Kurulum
- Real-time filesystem monitoring with `chokidar`
- Automatic mail decoding via `doveadm`
- Next.js Webhook integration
- Secure secret-based authentication
## Setup Instructions ### 1. Dosyaları Hazırlayın
Proje dizinine gidin ve `.env` dosyasını düzenleyin:
### 1. Configuration
Create a `.env` file in the root directory (copy from `.env.example` if available):
```env ```env
NEXTJS_WEBHOOK_URL=https://your-nextjs-app.com/api/webhooks/mail-signal NEXTJS_WEBHOOK_URL=https://webmail.ayris.tech/api/webhooks/mail-signal
WEBHOOK_SECRET=your_secret_here WEBHOOK_SECRET=besiktasK1903*
``` ```
### 2. Local Installation ### 2. Yerel Çalıştırma
Node.js (v18+) yüklü olduğundan emin olun:
```bash ```bash
npm install npm install
npm start npm start
``` ```
### 3. Docker Deployment ### 3. Docker ile Çalıştırma
To run as a container, you must provide access to the Docker socket and the Mailcow volumes: En güvenli ve kolay yöntem Docker konteyneri olarak çalıştırmaktır:
```bash ```bash
# Resmi oluşturun
docker build -t ayristech-worker . docker build -t ayristech-worker .
# Konteyneri başlatın
docker run -d \ docker run -d \
--name ayristech-worker \ --name ayristech-worker \
-v /var/run/docker.sock:/var/run/docker.sock \ -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/ \ -v /var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/_data/:/var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/_data/ \
--env-file .env \ --env-file .env \
--restart unless-stopped \
ayristech-worker ayristech-worker
``` ```
## Important Notes ## Önemli Notlar
- **Docker Socket**: The worker runs `docker exec` commands, so `/var/run/docker.sock` must be mounted. - **Docker Socket**: Servis `docker exec` komutu kullandığı için `/var/run/docker.sock` mount edilmelidir.
- **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. - **Vmail Volümü**: Mailcow'un mail dosyalarını sakladığı volüm `/var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/_data/` yoluna mount edilmelidir.

161
package-lock.json generated
View File

@@ -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"
}
}
}

16
package.json Normal file
View File

@@ -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"
}
}

View File

@@ -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,
}
}