This project is a Laravel-based application for fetching articles from various sources and serve them with the native API. Follow the instructions below to set up and run the project. Documentation of the API is inside /routes/api.php
git clone https://github.com/ktsouvalis/articles.git
cd articlescomposer installCopy the example environment file and set up your environment variables:
copy .env.example .env
php artisan key:generateInside the .env file, set your database connection details for MySQL or the path to your SQLite file.
Also set your enviroment variables for the sources:
GUARDIAN_API_URL=content.guardianapis.com/search
GUARDIAN_API_KEY=your-guardian-key
NYTIMES_API_URL=api.nytimes.com/svc/search/v2/articlesearch.json
NYTIMES_API_KEY=your-nytimes-key
NEWSAPI_API_URL=newsapi.org/v2/everything
NEWSAPI_API_KEY=your-news-api-keyRun the database migrations to set up the necessary tables:
php artisan migrateYou will need to run the following commands in three separate terminal windows:
php artisan servephp artisan queue:workphp artisan app:call-sources <keeperClassName>php artisan schedule:work- Locate the `Keeper` class in your project.
- Add a new record to the sources array for your chosen API source. This will typically involve specifying the source name and any necessary configuration details. You have to study your choice's API Documentation
OR Create a new keeper class (if the first one becomes extremely large or if you need a different scheduling):
- Create a new keeper class inside `app/Services/Keepers/`
- The new class must implement SourceKeeper Interface
- Check the `app/Services/Keepers/Keeper.php` as an example
The project is licensed under the MIT license.