Skip to content
Hussein Hany edited this page Sep 29, 2023 · 1 revision

MiniMessageBoard Documentation

MiniMessageBoard is a web application that allows users to post and view messages. This documentation provides a step-by-step guide to understanding, setting up, and using the application.

Table of Contents

Table of Contents

  1. Overview
  2. Installation
  3. Usage
  4. Configuration
  5. Acknowledgments

Overview

MiniMessageBoard is built using Node.js, Express.js, and MongoDB. It provides a simple interface for users to interact with messages. Messages are stored in a MongoDB database for persistence, and users can view existing messages and submit new ones.

Installation

To run MiniMessageBoard locally, follow these steps:

  1. Clone the repository: git clone https://github.com/3ein39/MiniMessageBoard.git

  2. Install project dependencies: npm install

  3. Create a .env file in the project root directory with the following content: MONGO_URL=

Replace <your-mongodb-uri> with your MongoDB connection URI.

  1. Start the application:
  2. Open your web browser and visit http://localhost:3000 to access MiniMessageBoard.

Usage

Viewing Messages

The main route / displays existing messages. You can see the sender's name and the timestamp of each message.

Posting Messages

  1. Visit the /new route to access the new message form.
  2. Fill out the form with your name and message text.
  3. Click the "Submit" button to send your message.
  4. After submitting, you'll be redirected to the index page, where your new message will appear.

Endpoints

MiniMessageBoard provides the following endpoints for interacting with the application:

  • GET /: This endpoint allows users to view existing messages. It displays messages with the sender's name and message timestamp.

  • GET /new: Accessing this endpoint takes users to the new message form, where they can submit new messages.

  • POST /new: This endpoint is used to submit new messages. Users can fill out the form with their name and message text and click the "Submit" button. The message is then added to the list of messages.

These endpoints allow users to both view and contribute to the MiniMessageBoard application, making it easy to interact with messages.

Message Schema

The Message Schema defines the structure of messages stored in the MiniMessageBoard application. It is implemented using Mongoose, a MongoDB ODM (Object Data Modeling) library for Node.js.

Fields

  • text (String): The content of the message.
  • user (String): The name of the user who sent the message.
  • added (Date): The timestamp when the message was added. It defaults to the current date and time.

Example

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const messageSchema = new Schema({
    text: String,
    user: String,
    added: { type: Date, default: Date.now }
});

const Message = mongoose.model('Message', messageSchema);

module.exports = Message;

Acknowledgments

  • Special thanks to The Odin Project for providing educational resources.
  • [EJS] for rendering dynamic views.