feat: add email-server-worker with clean template architecture
Add new email-server-worker project implementing a self-scheduling background worker pattern with HTTP monitoring. Removed all business-specific code from copied source, creating a clean, reusable template. Key features: - Self-scheduling worker loop with configurable interval - Graceful shutdown support (Docker-compatible) - Prometheus metrics collection - Health check endpoints (/healthcheck, /metrics, /ping) - Example worker template for easy customization - Comprehensive architecture documentation in CLAUDE.md The worker is now ready for email server implementation with no external dependencies on Evolution/MSSQL/ElasticSearch. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
33
email-server-worker/tests/helpers/mockHttpContext.ts
Normal file
33
email-server-worker/tests/helpers/mockHttpContext.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import { NgitLocals } from "../../src/types/NgitLocals";
|
||||
|
||||
interface IMockHttpContext {
|
||||
reqPath?:string
|
||||
headersSent?:boolean
|
||||
writableEnded?:boolean
|
||||
method?:string
|
||||
}
|
||||
|
||||
export const mockHttpContext = ({reqPath="/", headersSent=false, writableEnded=false, method="GET"}:IMockHttpContext|undefined = {}) => {
|
||||
const req = {
|
||||
path:reqPath,
|
||||
method,
|
||||
url:`https://localhost${reqPath}`,
|
||||
params: {},
|
||||
} as unknown as Request;
|
||||
|
||||
const res = {
|
||||
end: jest.fn(),
|
||||
status: jest.fn(),
|
||||
setHeader: jest.fn(),
|
||||
locals: {
|
||||
stopPrometheusTimer: jest.fn(),
|
||||
} as unknown as NgitLocals,
|
||||
headersSent,
|
||||
writableEnded,
|
||||
} as unknown as Response;
|
||||
|
||||
const next:NextFunction = jest.fn();
|
||||
|
||||
return({req,res,next})
|
||||
}
|
||||
Reference in New Issue
Block a user