Skip to content

Backend of a web app for tailored news. Explore trending topics, get personalized feeds, bookmark articles, and engage via comments.

Notifications You must be signed in to change notification settings

bojana-petroska/News-App-Server

 
 

Repository files navigation

News Aggregator Backend

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.


Features

  • 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.

Tech Stack

  • 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.

Prerequisites

Ensure the following are installed:


Setup and Installation

1. Clone the Repository

git clone https://github.com/yourusername/news-aggregator-backend.git
cd news-aggregator-backend

2. Set Up Environment Variables

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

3. Install Dependencies

npm install

4. Run the Development Server

npm run dev

Using Docker

This project includes a Dockerfile and docker-compose.yml for easy containerization.

1. Build and Run the Container

docker-compose up --build

2. Access the Application

  • The backend will be accessible at http://localhost:4000.

3. Stop the Container

docker-compose down

API Endpoints

Authentication

  • POST /api/auth/register: Register a new user.
  • POST /api/auth/login: Login with email and password.

News

  • 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.

Users

  • GET /api/users/me: Fetch user profile.
  • PUT /api/users/update: Update user profile.

Scripts

  • 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

Testing

Run tests with:

npm test

This project uses Jest for testing. Integration and unit tests are located in the tests/ directory.

Lint and Test Docker Build

--

Contributing

  1. Fork this repository.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m "Add feature-name").
  4. Push to your branch (git push origin feature-name).
  5. Open a Pull Request

About

Backend of a web app for tailored news. Explore trending topics, get personalized feeds, bookmark articles, and engage via comments.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.4%
  • JavaScript 5.5%
  • Other 1.1%