This is the backend of the Personalized News Aggregator App, built using TypeScript, Express.js, and containerized with Docker. It provides REST APIs for fetching, managing, and interacting with news articles and user data.
- Modular architecture for scalability and maintainability.
- API endpoints for:
- User authentication and management.
- Fetching and storing news articles.
- Bookmarking and commenting on articles.
- Validation with JOI for robust data handling.
- Unit and integration tests with Jest.
- Dockerized setup for easy deployment.
- TypeScript: Strongly typed programming for scalable backend development.
- Express.js: Lightweight and fast web framework for Node.js.
- Docker: Containerization for consistent environments.
- JOI: Schema-based data validation.
- Jest: Comprehensive testing framework for the backend.
Ensure the following are installed:
- Node.js (v18+ recommended)
- Docker and Docker Compose
- npm or yarn
git clone https://github.com/yourusername/news-aggregator-backend.git
cd news-aggregator-backend
Create a .env
file in the root directory:
NODE_ENV=development
PORT=4000
NEWS_API_KEY=your_news_api_key
DATABASE_URL=your_database_url
JWT_SECRET=your_jwt_secret
npm install
npm run dev
This project includes a Dockerfile
and docker-compose.yml
for easy containerization.
docker-compose up --build
- The backend will be accessible at
http://localhost:4000
.
docker-compose down
- POST
/api/auth/register
: Register a new user. - POST
/api/auth/login
: Login with email and password.
- GET
/api/news
: Fetch all news articles. - POST
/api/news/bookmark
: Bookmark a news article. - POST
/api/news/comment
: Add a comment to a news article.
- GET
/api/users/me
: Fetch user profile. - PUT
/api/users/update
: Update user profile.
- Start Development Server:
npm run dev
- Run Production Server:
npm start
- Run Tests:
npm test
- Lint and Fix Code:
npm run lint
- Build for Production:
npm run build
Run tests with:
npm test
This project uses Jest for testing. Integration and unit tests are located in the tests/
directory.
--
- Fork this repository.
- Create a feature branch (
git checkout -b feature-name
). - Commit your changes (
git commit -m "Add feature-name"
). - Push to your branch (
git push origin feature-name
). - Open a Pull Request