This project was generated with Angular CLI version 16.1.0.
This is a simple web application that utilizes the NY Times API to display a list of most popular articles. It provides features such as categorized top news, article search and user registration/login functionality.
Users can choose between two categories, "World" and "Science," to view a list of top news articles specific to each category.
Users can search for articles by entering keywords in the search input. The app provides pagination support for fetching more results as the user navigates through the pages. Stores history of last 5 searched words.
When clicking on an article, users can view the article details, including its abstract, web URL, snippet, lead paragraph, print section, print page, source, multimedia, headline, byline, publication date, and keywords.
The app includes user registration and login screens that are integrated with a local server. The server can be accessed at http://localhost:8000/. User authentication is handled using JSON Web Tokens (JWT), and the token received during the login process is passed through to NY Times API requests in the Authorization JWT Bearer token header. If you encounter any registration or login issues,please restart the server.
A middleware is implemented to automatically refresh the token after 15 minutes or whenever it expires, ensuring a seamless user experience.
NY Times Top Stories API: https://developer.nytimes.com/docs/top-stories-product/1/overview NY Times Article Search API: https://developer.nytimes.com/docs/articlesearch-product/1/overview
- Clone the repository: git clone <repository_url>
- Install dependencies: npm install
- Set up the server: Configure the local server using the instructions provided in the https://github.com/techiediaries/fake-api-jwt-json-server. Follow the instructions in the repository's README to set up and run the server at http://localhost:8000/.
- Obtain an NY Times API Key: Go to the NY Times Developer Portal - https://developer.nytimes.com/. Sign up for an account and create an API key. Copy the API key. Replace the API_KEY constant with your NY Times API key in constants.ts
- Start the application: npm start
- Open the app in your browser: http://localhost:4200
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The application will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
The app was developed as a part of a coding exercise or project assignment. Special thanks to the NY Times for providing access to their API.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI Overview and Command Reference page.