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

post-manager

v1.0.0

Published

This npm package provides functionality for managing posts, including creating posts, fetching posts, and adding comments and adding reaction on post. It is built with Node.js, Express, and MongoDB.

Downloads

2

Readme

Post Manager Package

This npm package provides functionality for managing posts, including creating posts, fetching posts, and adding comments and adding reaction on post. It is built with Node.js, Express, and MongoDB.

Installation

To use this package in your project, you can install it via npm:

npm install post-manager

Usage

Initializing the Database Connection Before using the package functions, initialize the database connection by providing your MongoDB connection string:

const communityPackage = require('post-manager');

const mongoUrl = 'Your mongo URL';

communityPackage.initializeDatabase(mongoUrl);

Functions

Create a Post

const media = [{
        type:'img', // 'img', 'pdf', 'video', 'gif', 'emoji', 'other'
        url:"url"   // Url of Media 
    }]
const postData = {
    title:"Post Title", // Mandatory to pass
    description:"Post Description", // Optional
    media:media // Optional
}

const newPost = communityPackage.createPost(userId,postData);  

console.log('New Post:', newPost);

Update Post

const media = [{
        type:'img', // 'img', 'pdf', 'video', 'gif', 'emoji', 'other'
        url:"url"   // Url of Media 
    }]
const postData = {
    title:"Post Title", // Mandatory to pass
    description:"Post Description", // Optional
    media:media // Optional
}

const slug = "your-post-slug" // replace with your actual slug of Post

const updatePost = communityPackage.updatePost(postData,slug);  

console.log('Post Updated:', updatePost);

Get Single Post Details

 const collection_info = {
      user_collection: "users", // User Collection name
      user_name: "name", // key name of user name
      user_avatar: "avatar", // key name of user avatar
      product_collection: "products", // product collection name
      product_name: "name",
      product_logo: "imgUrl",
      product_slug: "slug"
    }
    
const slug = "your-post-slug" // replace with your actual slug of Post

const Post = communityPackage.getSinglePost(collection_info,slug);  

console.log('Post:', Post);

Delete Post

    
const slug = "your-post-slug" // replace with your actual slug of Post

const deletePost = communityPackage.deletePost(slug);  

console.log('Post:', deletePost);

Get All Posts

const allPosts = communityPackage.getAllPosts();

console.log('All Posts:', allPosts);

Add a Comment to a Post

const postId = '1234567890'; // Replace with an actual post ID

const commentData = {
    text:"Osm",
    parent:"1234567890"  // if you reply any comment then only pass the parent (comment id) other wise no need.
}

const newComment = communityPackage.addComment(postId,commentData);

console.log('New Comment:', newComment);

Update Comment

const commentId = '1234567890'; // Replace with an actual comment ID

const commentData = {
    text:"Osm",
}

const updateComment = communityPackage.editComment(commentId,commentData);

console.log('Update Comment:', updateComment);

Delete Comment

const commentId = '1234567890'; // Replace with an actual comment ID
const postId = '1234567890'; // Replace with an actual Post ID

const deleteComment = communityPackage.deleteComment(commentId,postId);

console.log('Delete Comment:', deleteComment);

All Comment

const collection_info = {
      user_collection: "users", // User Collection name
      user_name: "name", // key name of user name
      user_avatar: "avatar", // key name of user avatar
    }
const postId = '1234567890'; // Replace with an actual Post ID

const allComment = communityPackage.allComments(collection_info,postId);

console.log('Comment:', allComment);

Add a Reaction to a Post

const postId = '1234567890'; // Replace with an actual post ID

const reactionData = {
    text:"👍"
}

const newReaction = communityPackage.addReaction(postId,reactionData);

console.log('New Reaction:', newComment);

Change Reaction

const reactionId = '1234567890'; // Replace with an actual Reaction ID

const reactionData = {
    text:"👎"
}

const changeReaction = communityPackage.editReaction(reactionId,reactionData);

console.log('Change Reaction:', changeReaction);

Remove Reaction

const reactionId = '1234567890'; // Replace with an actual Reaction ID
const postId = '1234567890'; // Replace with an actual Post ID

const removeReaction = communityPackage.deleteReaction(reactionId,postId);

console.log('Remove Reaction:', removeReaction);

All Reaction

 const collection_info = {
      user_collection: "users", // User Collection name
      user_name: "name", // key name of user name
      user_avatar: "avatar", // key name of user avatar
    }
    
const postId = '1234567890'; // Replace with an actual Post ID

const Reactions = communityPackage.allReactions(collection_info,postId);

console.log('Reactions:', Reactions);

All Post of a Product

 const collection_info = {
      user_collection: "users", // User Collection name
      user_name: "name", // key name of user name
      user_avatar: "avatar", // key name of user avatar
      product_collection: "products", // product collection name
      product_name: "name",
      product_logo: "imgUrl",
      product_slug: "slug"
    }
    
const productId = '1234567890'; // Replace with an actual Post ID

const Data = communityPackage.allPostByProduct(collection_info,productId);

console.log('Data:', Data);

License

This package is licensed under the MIT License - see the LICENSE file for details.

Issues and Contributions

Feel free to open issues for bug reports, feature requests, or any suggestions. Contributions are also welcome. Please follow the contribution guidelines.

Make sure to include the appropriate license file (e.g., LICENSE) and create a CONTRIBUTING.md file if you want to specify how others can contribute to your project. Update the placeholders like your-database-name with actual details relevant to your package.