New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

comment-extensible

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comment-extensible

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

latest
npmnpm
Version
0.1.1
Version published
Maintainers
0
Created
Source
comment-extensible

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
  • Setup
  • Usage
  • Contribution
  • License

Installation

To install the package, use npm or yarn:

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

Setup

MongoDB

  • Configure MongoDB Connection

    Create a file mongoConfig.ts:

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

PostgreSQL

  • 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,
    };
    
  • 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:

  • Fork the repository on GitHub.

  • Clone your fork locally:

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

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

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

    git push origin feature/your-feature-name
    
  • 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.

Keywords

nextjs

FAQs

Package last updated on 28 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts