feat: initialize news service with core functionality

- Add package.json for project configuration and dependencies.
- Implement NewsApplication class to manage service lifecycle and HTTP pipeline.
- Create CategoryCatalog for managing news categories.
- Introduce ServiceConfig for environment variable management.
- Load environment variables from .env files.
- Develop NewsApiCompatibilityController to mimic NewsAPI endpoints.
- Create NewsController for querying and refreshing news data.
- Establish AbstractJsonRepository for JSON storage operations.
- Implement main entry point in index.js to bootstrap the application.
- Create CategoryNewsRepository for category-specific news storage.
- Add ConsoleLogger for structured logging.
- Implement NewsApiClient for fetching articles from NewsAPI.
- Develop NewsRefreshScheduler for scheduling news refresh tasks.
- Create NewsStorageService to coordinate news data management.
This commit is contained in:
2026-04-30 12:10:00 +08:00
commit 3d891d781c
21 changed files with 1901 additions and 0 deletions

21
docker-compose.yml Normal file
View File

@@ -0,0 +1,21 @@
version: '3.9'
services:
news-service:
build: .
container_name: news-service
env_file:
- .env.example
ports:
- "3100:3100"
environment:
PORT: 3100
NEWS_API_KEY: ${NEWS_API_KEY}
NEWS_API_BASE_URL: ${NEWS_API_BASE_URL:-https://newsapi.org/v2/everything}
NEWS_API_LANGUAGE: ${NEWS_API_LANGUAGE:-en}
NEWS_PAGE_SIZE: ${NEWS_PAGE_SIZE:-20}
NEWS_REFRESH_CRON: ${NEWS_REFRESH_CRON:-0 * * * *}
DATA_DIR: ${DATA_DIR:-/app/data}
volumes:
- ./data:/app/data
restart: unless-stopped