https://blogbox-oy51.onrender.com/
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.
- 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
- Node.js, Express
- EJS for server-side templates
- Multer for file uploads
- body-parser and static assets via Express
- Node.js 18+
- npm
- Set "type": "module" in package.json for ES module imports
- 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/
- Start server: node app.js
- Visit: http://localhost:3000
- 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
- Multer stores files in public/images/
- Uploaded image served at /images/
- Ensure public/images/ is writable
- index.ejs: { posts }
- posts.ejs: { posts }
- edit-post.ejs: { post }
- single_post.ejs: { post }
- In-memory storage (global.posts) is not persistent
- No authentication or validation
- Not production-ready (no database, no security hardening)
- 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