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>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import express from 'express';
|
|
import createError from 'http-errors';
|
|
|
|
import { errorRouter } from './routes/errorRouter';
|
|
import { finalErrorRouter } from './routes/finalErrorRouter';
|
|
import { metricsRouter } from './routes/metricsRouter';
|
|
import { pingRouter } from './routes/pingRouter';
|
|
import { healthcheckRouter } from './routes/healthcheckRouter';
|
|
|
|
import { SupportedRoutes } from './types/enums/SupportedRoutes';
|
|
|
|
const app = express();
|
|
|
|
// u slučaju kada se server vrti iza proxy-a
|
|
// ovaj flag će natjerati Express da informacije poput
|
|
// IP adrese klijenta, protokola uzima iz X-Forward-*
|
|
// HTTP header polja, koja postavlja proxy
|
|
app.set('trust proxy', true);
|
|
|
|
// prometheus sa ove rute dohvaća zadnje važeću statistiku
|
|
app.use(SupportedRoutes.metricsPath, metricsRouter);
|
|
app.use(SupportedRoutes.ping, pingRouter);
|
|
app.use(SupportedRoutes.healthcheck, healthcheckRouter);
|
|
|
|
// default handler
|
|
app.use((req, res, next) => next(createError(404)));
|
|
|
|
// error handler za sve predviđene greške
|
|
app.use(errorRouter);
|
|
|
|
// error router za nepredviđene greške
|
|
app.use(finalErrorRouter);
|
|
|
|
export default app;
|