Skip to content

Instantly share code, notes, and snippets.

View Silent-Watcher's full-sized avatar
🛸
loading ...

Ali nazari Silent-Watcher

🛸
loading ...
View GitHub Profile
@Silent-Watcher
Silent-Watcher / docker-compose.dev.yml
Created October 7, 2025 18:52
Kafka docker local service
version: "3.8"
services:
kafka:
image: apache/kafka:4.0.1-rc2
container_name: kafka
ports:
- "9092:9092"
environment:
CLUSTER_ID: mkqv8X5vRla7PzR8bKqfHk
@Silent-Watcher
Silent-Watcher / docker-compose.dev.yml
Created October 7, 2025 16:45
local ElasticSearch and Kibana setup with docker compose
version: '3.8'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.3
container_name: elasticsearch
environment:
- node.name=es-node
- discovery.type=single-node
- cluster.name=es-cluster
@Silent-Watcher
Silent-Watcher / versions.md
Created July 2, 2025 23:05
nodejs ABI version
Node.js Version ABI Version (NODE_MODULE_VERSION)
16.x 93
18.x 108
20.x 115
21.x 124
22.x 131
@Silent-Watcher
Silent-Watcher / process.ts
Created June 30, 2025 20:13
process handler in node.js
export function setupProcessHandlers(options?: {
exitOnError?: boolean;
onError?: (type: 'uncaughtException' | 'unhandledRejection', error: any) => void;
}) {
const exit = options?.exitOnError ?? true;
const onError = options?.onError;
process.on('uncaughtException', (err) => {
console.error('[🔥 Uncaught Exception]:', err);
onError?.('uncaughtException', err);
@Silent-Watcher
Silent-Watcher / table.md
Created June 27, 2025 21:03
The Silent Killers in Node.js: uncaughtException and unhandledRejection
✅ Do ❌ Don’t
Log full stack traces and context (request IDs, payloads, etc.) Continue running as if nothing happened
Report to external error‑tracking services (Sentry, Datadog, etc.) Swallow errors or leave handlers empty
Gracefully shut down: close DB, stop accepting new requests Call process.exit(0) (signals success)
Use a supervisor (e.g., PM2, Docker restart policy) Believe you can recover 100% safely in‑process
Convert unhandled rejections into exceptions (throw reason) Ignore Node.js v15+ default behavior—explicit is better
Label Threshold Action
Adult Nudity >90% Reject
Violence >80% Quarantine
Self-Harm >70% Manual Review

badge

@Silent-Watcher
Silent-Watcher / jose.md
Created May 30, 2025 10:04
jose vs jsonwebtoken
Feature jose jsonwebtoken
TypeScript Support ✅ Native ☑️ Partial
ESM Support ✅ Yes ❌ No
Browser Compatibility ✅ Yes ❌ No
Algorithm Support ✅ Broad (EdDSA, ES, PS, etc.) ⚠️ Limited
Maintenance ✅ Active (Panva) 💤 Slow
Crypto Security ✅ Uses native Web Crypto API ⚠️ Custom crypto
API Style ✅ Promise-based, functional ❌ Callback/Sync
@Silent-Watcher
Silent-Watcher / helper.ts
Created May 29, 2025 13:32
Express.js+Redis Cache middleware
import { unwrap } from "#app/config/db/global";
import { rawRedis, redis } from "#app/config/db/redis/redis.config";
import type { Request } from "express";
import type { RedisKey } from "ioredis";
import hash from "object-hash";
import type { RedisSetOptions } from "#app/config/db/redis/types";
import type { CommandResult } from "#app/config/db/global";
import { logger } from "#app/common/utils/logger.util";
function buildRedisSetArgs(options: RedisSetOptions): (string | number)[] {
@Silent-Watcher
Silent-Watcher / EmailTools.md
Created May 22, 2025 09:34
Email Testing Tools (Dev & QA)

🧪 Email Testing Tools (Dev & QA)

Tool Type Description
MailHog Self-hosted Open-source email testing tool for local dev. Provides a local SMTP + UI.
Mailtrap Cloud Cloud-based service for capturing and inspecting emails. Great UI & team features.
Papercut SMTP Self-hosted Windows-friendly, lightweight desktop email testing tool.
FakeSMTP Self-hosted Java-based email testing server with GUI. Captures SMTP traffic.
MailCatcher Self-hosted Ruby-based local email testing with web UI. Simple and effective.
Ethereal Email Cloud Free fake SMTP service by Nodemailer. No real delivery — inspect via URL.