npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

comment-extensible

v0.1.1

Published

A React.js package for handling comments, supporting one level of replies and being database agnostic.

Downloads

4

Readme

Nextjs Comment Extensible

This ReactJS package provides a comments component with one level deep replies. It is designed to be database agnostic, supporting MongoDB and PostgreSQL and more...

Features

  • 💬Commenting system with one level deep replies
  • 📦Database agnostic: works with MongoDB, PostgreSQL and more...
  • 🎉Easy to integrate into existing React projects

Table of Contents

Installation

To install the package, use npm or yarn:

npm install comment-extensible
# or
yarn add comment-extensible

Setup

MongoDB

  1. Configure MongoDB Connection

    Create a file mongoConfig.ts:

    export const mongoConfig = {
      mongoDBUrl: "your-mongodb-url",
      dbName: "your-database-name",
      collectionName: "comments",
    };
  2. Ensure MongoDB is running and the connection URL is correctly set.

PostgreSQL

  1. Configure PostgreSQL Connection

    Create a file postgresConfig.ts:

    export const postgresConfig = {
      user: "your-db-user",
      host: "your-db-host",
      database: "your-database-name",
      password: "your-db-password",
      port: 5432,
    };
  2. Ensure PostgreSQL is running and the connection parameters are correctly set.

Usage

Import and Use the Comment Component

Here's how you can use the Comment component in your React application for Mongo & Postgres:

// App.js
"use client";

import { CommentSection, MongoCommentRepository } from "comment-extensible";

export default function Home() {
  const { mongoDBUrl, dbName, collectionName } = {
    mongoDBUrl: "mongodb://localhost:27017",
    dbName: "comment-extensible",
    collectionName: "comment",
  };

  const commentRepository = new MongoCommentRepository(
    mongoDBUrl,
    dbName,
    collectionName
  );

  return <CommentSection commentRepository={commentRepository} />;
}
// App.js ⚠️⚠️⚠️ Work in progress - will be out in the next version
"use client";

import { CommentSection, PostgresCommentRepository } from "comment-extensible";

export default function Home() {
  const poolOptions = {
    user: "postgres",
    host: "localhost",
    database: "comment-extensible",
    password: "YOUR_PASSWORD",
    port: 5432,
  };

  const commentRepository = new PostgresCommentRepository(poolOptions);

  return <CommentSection commentRepository={commentRepository} />;
}

Contribution

We welcome contributions to enhance this package. To contribute, follow these steps:

  1. Fork the repository on GitHub.

  2. Clone your fork locally:

    git clone https://github.com/PiusLucky/comment-extensible.git
  3. Create a new branch for your feature or bugfix:

    git checkout -b feature/your-feature-name
  4. Make your changes and commit them:

    git add .
    git commit -m "Add your commit message"
  5. Push your changes to your fork:

    git push origin feature/your-feature-name
  6. Create a Pull Request on GitHub.

Code of Conduct

Please read our Code of Conduct before contributing to ensure respectful collaboration.

Running Tests

Before submitting a pull request, ensure that all tests pass:

npm test
# or
yarn test

License

This project is licensed under the MIT License. See the LICENSE file for details.