A simple, lightweight message board built with Node.js, Express, and SQLite. Users can post messages to a public board, with built-in rate limiting for security and persistence using a local SQLite database.
- Post messages to a shared message board
- View all messages in reverse chronological order (newest first)
- Rate limiting to prevent spam (10 messages per minute per IP, 100 requests per 15 minutes)
- Input validation and sanitization
- Responsive design that works on mobile and desktop
- Persistent storage with SQLite database
- Node.js (version 12 or higher)
- npm
-
Install dependencies: npm install
-
Start the server: npm start
The server will run on http://localhost:3000 by default.
The application consists of three main parts:
-
Backend Server (server.js) - Handles GET requests to display the message board and POST requests to submit new messages. Implements rate limiting using express-rate-limit middleware.
-
Database Module (db.js) - Manages SQLite database operations. Creates a messages table with author, content, and timestamp fields.
-
Frontend (public/index.html, public/styles.css, public/app.js) - A simple HTML interface where users can enter their name and message, and view all posted messages.
GET / - Serves the main message board page
POST / - Submits a new message (requires author and message form fields)
GET /api/messages - Returns all messages as JSON
The application implements two rate limiters:
Global Limiter: 100 requests per 15 minutes per IP address Post Limiter: 10 messages per minute per IP address
If rate limits are exceeded, the server returns a 429 error message.
- Author name: Maximum 100 characters
- Message content: Maximum 500 characters
The SQLite database contains a single table:
messages
- id (integer, auto-increment primary key)
- author (text, required)
- content (text, required)
- created_at (timestamp, defaults to current time)
To change the port, set the PORT environment variable:
PORT=5000 npm start
To modify rate limits, edit the configuration in server.js:
- windowMs: Time window in milliseconds
- max: Maximum requests allowed in the time window
project/
- server.js - Main Express server
- db.js - SQLite database module
- public/
- index.html - HTML page template
- styles.css - Styling
- app.js - Frontend JavaScript
- messages.db - SQLite database file (created automatically)