Kacy Phan Logo Image
Kacy Phan

News Times

Languages, Frameworks, & Libraries Used

Bulma
Bootstrap
Express.js
JavaScript
Node.js
NPM
PostgreSQL
Postman

Project Overview

News Times is a web application that allows users to browse and read news articles from a variety of sources. The app provides features such as article browsing, full-text reading, and saving articles for later. The app implements essential functionality related to its goal. The app includes a GET, POST, DELETE, and PUT routes. The app utilizes the News API from Google and implements advanced database relationships.

newsArticles

The app utilizes the News API from Google and implements advanced database relationships. The following user stories have been identified for the News App: 1. User able to browse a list of news articles from different sources. 2. User able to read the full text of news articles. 3. User able to save news articles to read later.

newsArticles

The API provided is a 1 out of 10 GET route handler function that handles the /apple route. The code sends a request to the News API to fetch articles related to apple. Depending on the response status, it renders the retrieved articles in the apple view template, or sends JSON responses with specific error messages if there are issues with the request or response.

savedArticles

To save articles a router POST handler function handles the /add route. It is a protected route isLoggedIn middleware is used that requires authentication to access. The function receives the HTTP request req and response res objects as parameters. The article data is then saved to a database or any other data source using an article model. The create method is called on the article model with the extracted data and additional processing on content and description fields (slicing the content to 250 characters). If the article is successfully saved, the server redirects the user back to the /savedArticles page. If an error occurs during the process, it is caught in the catch block, and an error message is logged to the console. The server responds with a status code of 500 Internal Server Error and sends an error message as the response body.

userProfile

A PostgreSQL table is use to displays user information, including their ID, name, email, password, active status, creation date, and update date. When displaying user information, if a user is marked as 'active,' it means their account is active and they can log in. However, if a user is marked as 'false,' it indicates that they have deleted their account and can no longer log in. In such cases, they will need to create a new user account.

Entity Relationship Diagram

edr