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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@joacogdelr/news-entities

v1.4.8

Published

Shared entities and migrations for news applications

Readme

News Entities

Shared TypeORM entities and database migrations for the news application ecosystem.

Installation

npm install news-entities

Usage

Basic Usage

import { AppDataSource, Article, Story, Source } from 'news-entities';

// Initialize the data source
await AppDataSource.initialize();

// Use entities in your repositories
const articleRepository = AppDataSource.getRepository(Article);
const articles = await articleRepository.find();

Custom Data Source Configuration

import { createDataSource } from 'news-entities';

const customDataSource = createDataSource({
  host: 'custom-host',
  port: 5433,
  database: 'custom_db',
});

await customDataSource.initialize();

Environment Variables

The following environment variables can be used to configure the database connection:

  • DB_HOST - Database host (default: localhost)
  • DB_PORT - Database port (default: 5432)
  • DB_USERNAME - Database username (default: postgres)
  • DB_PASSWORD - Database password (default: password)
  • DB_NAME - Database name (default: news_db)
  • NODE_ENV - Environment (set to 'development' for logging)

Migrations

⚠️ Important: Since this is a library package, it provides migration files and utilities but does not run migrations automatically. Each consuming application must manage its own migration execution.

Quick Start for Applications

import { MigrationRunner } from 'news-entities';

const runner = new MigrationRunner({
  host: process.env.DB_HOST,
  port: parseInt(process.env.DB_PORT || '5432'),
  username: process.env.DB_USERNAME,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
});

// Run migrations
await runner.run();

For Existing Applications (Migrating from Prisma)

If you're migrating from Prisma to TypeORM, see the detailed guide in MIGRATION_GUIDE.md.

Migration Management Scripts

Add these to your application's package.json:

{
  "scripts": {
    "migrate:run": "node scripts/migrate.js run",
    "migrate:revert": "node scripts/migrate.js revert", 
    "migrate:status": "node scripts/migrate.js status"
  }
}

Creating New Migrations

New migrations should be created in the news-entities repository:

# In news-entities directory
npm run migration:generate -- -n MigrationName

📖 See MIGRATION_GUIDE.md for complete documentation

Entities

Core Entities

  • Source - RSS feed sources
  • RssEntry - Raw RSS feed entries
  • ScrapedArticle - Scraped content from RSS entries
  • Article - Processed articles with AI analysis
  • Story - Collections of related articles
  • Fact - Facts extracted from stories
  • Tag - Tags associated with stories

Relationships

Source 1:N RssEntry 1:1 ScrapedArticle 1:1 Article N:M Story
                                                |           |
                                                N:M         1:N
                                                |           |
                                              Fact --------+
                                                |
                                              Story N:M Tag

Vector Embeddings

The following entities support vector embeddings for similarity search:

  • Article.embedding
  • Fact.embedding
  • Tag.embedding

Important:

  • Database columns are VECTOR(1536) (PostgreSQL vector extension)
  • Entity properties are string | null for TypeORM compatibility
  • Use raw SQL queries for vector operations (e.g., embedding <-> target_embedding)

Example vector similarity query:

SELECT id, title, (embedding <-> $1) AS distance 
FROM articles 
ORDER BY embedding <-> $1 
LIMIT 10

Development

Building

npm run build

Watch Mode

npm run build:watch