Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chinmaykunkikar/news-aggregator-api
A RESTful API that allows users to fetch news articles from multiple sources based on their preferences.
https://github.com/chinmaykunkikar/news-aggregator-api
airtribe expressjs newsapi nodejs rest-api
Last synced: 13 days ago
JSON representation
A RESTful API that allows users to fetch news articles from multiple sources based on their preferences.
- Host: GitHub
- URL: https://github.com/chinmaykunkikar/news-aggregator-api
- Owner: chinmaykunkikar
- Created: 2023-04-25T22:14:48.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-05-23T11:52:15.000Z (over 1 year ago)
- Last Synced: 2024-10-27T22:39:27.558Z (2 months ago)
- Topics: airtribe, expressjs, newsapi, nodejs, rest-api
- Language: JavaScript
- Homepage:
- Size: 198 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# News Aggregator API
### Assignment 02
**Problem Statement** -- Build a RESTful API that allows users to fetch news articles from multiple sources based on their preferences.
| Endpoint | Description |
| -----------------: | :------------------------------------------------------------- |
| `POST /register` | Register a new user. |
| `POST /login` | Log in a user. |
| `GET /preferences` | Retrieve the news preferences for the logged-in user. |
| `PUT /preferences` | Update the news preferences for the logged-in user. |
| `GET /news` | Fetch news articles based on the logged-in user's preferences. |#### Tasks
- [x] Use an **in-memory data store** (e.g., an array) to store store user information and their news preferences.
- [x] Use **external news APIs to fetch** news articles from multiple sources. Incorporate async/await and Promises in the process of fetching news data and filtering it based on user preferences.
- [x] Implement proper **error handling** for invalid requests.
- [x] Add **input validation** for user registration and news preference updates.
- [x] **Test** the API using Postman or Curl to ensure it works as expected.##### Optional Tasks
- [ ] Implement a **caching mechanism** to store news articles and reduce the number of calls to external news APIs. Use async/await and Promises to handle cache updates and retrievals.
- [ ] Allow users to mark articles as "read" or "favorite". Implement endpoints to:| Endpoint | Description |
| --------------------------: | :------------------------------------------ |
| `POST /news/:id/read` | Mark a news article as read. |
| `POST /news/:id/favorite` | Mark a news article as a favorite. |
| `GET /news/read` | Retrieve all read news articles. |
| `GET /news/favorites` | Retrieve all favorite news articles. |
| `GET /news/search/:keyword` | Search for news articles based on keywords. |- [ ] Implement a mechanism to periodically update the cached news articles in the background, simulating a real-time news aggregator.
### Schema
```js
[
{
id: "string",
username: "string",
password: "string",
preferences: { categories: [Array], sources: [Array] },
// "createdAt": Date.now() // a.k.a Unix epoch // TODO
},
];
```