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

reviewmerce

v1.1.1

Published

Consume and insert reviews of articles for eccomerce.

Downloads

73

Readme

Reviewmerce

MIT licensed NPM Version

Welcome to Reviewmerce 👋

Table of Contents

Installation

Setup

npm i reviewmerce

As a start and first example, after installation, we need to create a starting point for our products, comments, and reviews, creating the most important, the company which governs all these data.

import ReviewMerceAPI from "reviewmerce";

const reviews = new ReviewMerceAPI();
const data = {
  name: "company",
};
const company = await reviews.products.company(data);

Products

checkExisting

To check if a product exists in our database using a boolean:

import ReviewMerceAPI from "reviewmerce";

const reviews = new ReviewMerceAPI();
const product = await reviews.products.checkExisting("1");

create

This part is the most important because here we have to use the name we used for our company, and ensure that our product we're creating is linked to this company. It's important to note that the product id is your selection so it can match your architecture; remember it's a string.

import ReviewMerceAPI from "reviewmerce";

const reviews = new ReviewMerceAPI();

const data = {
  id: "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c",
  name: "Elegant jacket",
  description: "Product description",
  companyName: "Company",
};

await reviews.products.create(data);

Reviews

Create user

To create a user for our reviews:

import ReviewMerceAPI from "reviewmerce";

const reviewMerceAPI = new ReviewMerceAPI();
const data = {
  username: "Standby",
};
const createUser = await reviewMerceAPI.reviews.createUser(data);

Create review

Using the product id we created, we submit our review rating from 1 to 5, and provide the username we created earlier.

import ReviewMerceAPI from "reviewmerce";

const reviewMerceAPI = new ReviewMerceAPI();

const data = {
  rating: 5,
  username: "Standby",
  productId: "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c",
};
const review = await reviewMerceAPI.reviews.create(data);

rating

Calculating the percentage rating of a product from 1 to 5:

import ReviewMerceAPI from "reviewmerce";
const reviewMerceAPI = new ReviewMerceAPI();
const rating = await reviewMerceAPI.reviews.rating(
  "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c"
);

product

if we want to see all the reviews in json format of our product it would be something like this;

import ReviewMerceAPI from "reviewmerce";
const reviewMerceAPI = new ReviewMerceAPI();
const rating = await reviewMerceAPI.reviews.product(
  "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c"
);

Comments

Create comment

Creating a comment based on an id; these comments can also be anonymous, so it's not necessary to have a pre-created user, although if it doesn't exist, it will be created automatically.

import ReviewMerceAPI from "reviewmerce";
const reviews = new ReviewMerceAPI();
const data = {
  text: "Does this jacket have more colors?",
  username: "Standby",
  productId: "0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c",
};
const comment = await reviews.comments.create(data);

Product

To view the comments of a product:

import ReviewMerceAPI from "reviewmerce";
const reviews = new ReviewMerceAPI();
const comment = await reviews.comments.product("0ee97738-fbdc-43a3-8e8e-2cbbf692ab7c");