Add Express.js/JavaScript implementation of phpblog with complete feature parity#3
Open
Add Express.js/JavaScript implementation of phpblog with complete feature parity#3
Conversation
…ased authentication Co-authored-by: Roberto Luis Bisbe <825331+rlbisbe@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces a complete JavaScript/Express.js version of the phpblog application that replicates the entire architecture and functionality of the original PHP implementation. The new implementation maintains the same user experience while providing a modern Node.js backend.
Requirements Implemented
Core Application Setup
Backend Functions (db.js)
Equivalent to backend.php functionality:
theTitle()- Function to fetch and display blog titleinit(callback)- Function to initialize and fetch all posts from databaseaddNewPost(title, text, callback)- Function to add new posts with title and text fieldsFrontend Routes
All routes matching the current PHP application:
GET /- Main blog page displaying all posts with login formPOST /login- Login route handling user authenticationGET /logout- Logout route clearing user sessionGET /admin- Admin panel route to view all posts (protected)GET /admin/new_post- Admin route to display new post form (protected)POST /admin/add_new_post- Admin route to add new posts (protected)Security & Authentication
requireAuthmiddleware to protect admin routesView Templates
All EJS templates replicating the existing PHP page layouts:
views/index.ejs- Main blog pageviews/login.ejs- Login result pageviews/logout.ejs- Logout confirmationviews/admin/index.ejs- Admin panelviews/admin/new_post.ejs- New post formviews/admin/add_new_post.ejs- Post creation resultFile Structure
Technical Details
Dependencies
express^4.18.2 - Web frameworkejs^3.1.9 - Template enginemysql2^3.6.5 - MySQL database clientcookie-parser^1.4.6 - Cookie parsing middlewarebody-parser^1.20.2 - Form data parsingDatabase Configuration
Matches original PHP configuration:
Authentication Credentials
robertopassword(MD5: 3bc2e28ca8940090c3d80c851784a5d5)Installation & Usage
Testing Checklist
Behavior Parity
All routes and functionality match the current PHP application behavior, ensuring:
Notes