Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Message Board

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.

Features

  • 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

Requirements

  • Node.js (version 12 or higher)
  • npm

Installation

  1. Install dependencies: npm install

  2. Start the server: npm start

The server will run on http://localhost:3000 by default.

How It Works

The application consists of three main parts:

  1. 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.

  2. Database Module (db.js) - Manages SQLite database operations. Creates a messages table with author, content, and timestamp fields.

  3. 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.

API Endpoints

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

Rate Limiting

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.

Input Limits

  • Author name: Maximum 100 characters
  • Message content: Maximum 500 characters

Database Schema

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)

Customization

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

File Structure

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)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages