Skip to content

sealubong2006/BlogBox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Readme File for Project

DEMO

https://blogbox-oy51.onrender.com/

Overview

A minimal blog web application built with Express, EJS, and Multer. It supports creating, listing, editing, viewing, and deleting posts with optional image uploads. Posts are stored in memory for development and reset on server restart.

Features

  • Home shows the latest 3 posts
  • List all posts
  • Create post with title, content, and optional image
  • Edit and delete posts
  • Single post view
  • Static About and Contact pages
  • Basic 404 handler

Tech stack

  • Node.js, Express
  • EJS for server-side templates
  • Multer for file uploads
  • body-parser and static assets via Express

Prerequisites

  • Node.js 18+
  • npm
  • Set "type": "module" in package.json for ES module imports

Setup

  • Install dependencies: npm install express body-parser multer ejs
  • Ensure EJS is configured: app.set('view engine', 'ejs') and a views directory exists
  • Create directories: public/, public/images/ (for uploads)
  • Add templates: index.ejs, posts.ejs, edit-post.ejs, single_post.ejs, about.ejs, contact.ejs
  • Serve static files from public/

Run

Routes

  • GET / — render home with latest 3 posts
  • POST /create-post — fields: title, content; file field: image; redirects with success alert
  • GET /posts — list all posts
  • GET /edit-post/:id — render edit form for a post
  • POST /update-post/:id — update title, content, and optionally image
  • POST /delete-post/:id — delete a post
  • GET /post/:id — single post view
  • GET /about — about page
  • GET /contact — contact page

Upload handling

  • Multer stores files in public/images/
  • Uploaded image served at /images/
  • Ensure public/images/ is writable

Templates expected data

  • index.ejs: { posts }
  • posts.ejs: { posts }
  • edit-post.ejs: { post }
  • single_post.ejs: { post }

Limitations

  • In-memory storage (global.posts) is not persistent
  • No authentication or validation
  • Not production-ready (no database, no security hardening)

Next steps

  • Add a database (e.g., SQLite, PostgreSQL, MongoDB)
  • Add input validation and error handling
  • Add authentication/authorization
  • Add pagination and search
  • Support image cleanup on post delete
  • Use environment variables for configuration and PORT
  • Add tests and CI
  • Containerize with Docker

About

BlogBox - A Blog web application developed using EJS, JS, HTML, CSS and Express Js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors