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

recommendation_system121

v1.0.2

Published

A generic content-based filtering recommendation system that can be used for various types of content, including movies, news articles, gadgets, and shopping items.

Downloads

6

Readme

Recommendation System

A generic content-based filtering recommendation system that can be used for various types of content, including movies, news articles, gadgets, and shopping items.

Installation

To install the package, run:

npm install recommendation-system121

Usage

Here's how you can use this recommendation system in an Express application.

Basic Setup

const express = require("express");
const cookieParser = require("cookie-parser");
const {
    createUser,
    addTag,
    addItemToTag,
    getRecommendedTags,
} = require("my-recommendation-system");

const app = express();
const port = 3000;

app.use(cookieParser());
app.use(express.json());

app.post("/create-user", (req, res) => {
    const { userId } = req.body;
    createUser(req, res, userId);
});

app.post("/add-tag", (req, res) => {
    const { userId, tagName } = req.body;
    addTag(req, res, userId, tagName);
});

app.post("/add-items", (req, res) => {
    const { userId, tagName, newItems } = req.body;
    addItemToTag(req, res, userId, tagName, newItems);
});

app.get("/recommendations", (req, res) => {
    const { userId, tagName } = req.query;
    const recommendations = getRecommendedTags(req, res, userId, tagName);
    res.json(recommendations);
});

app.listen(port, () => {
    console.log(`Server running at http://localhost:${port}`);
});

API

createUser(req, res, userId)

Creates a user cookie if it doesn't exist.

Parameters:

  • req: The HTTP request object.
  • res: The HTTP response object.
  • userId: The unique user identifier.

addTag(req, res, userId, tagName)

Adds a tag with 3 epochs to the user's cookie.

Parameters:

  • req: The HTTP request object.
  • res: The HTTP response object.
  • userId: The unique user identifier.
  • tagName: The tag name to be added.

addItemToTag(req, res, userId, tagName, newItems)

Adds items to the first epoch of the specified tag. If a new week has started, it shifts the epochs.

Parameters:

  • req: The HTTP request object.
  • res: The HTTP response object.
  • userId: The unique user identifier.
  • tagName: The tag name to which the items will be added.
  • newItems: The new items to be added. Can be a single item or an array of items.

getRecommendedTags(req, res, userId, tagName)

Retrieves recommended items based on the epochs, selecting 3 items from the first epoch, 2 from the second, and 1 from the third.

Parameters:

  • req: The HTTP request object.
  • res: The HTTP response object.
  • userId: The unique user identifier.
  • tagName: The tag name whose recommendations are to be retrieved.