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

newzen-blog

v1.0.11

Published

My new Nuxt module

Readme

Newzen Blog

npm version npm downloads License Nuxt

A powerful Nuxt module for managing blog content with built-in SQLite database integration using Drizzle ORM.

Features

  • 📝  Blog management with SQLite database
  • 🗄️  Database migrations with Drizzle ORM
  • 🔌  Server-side API for blog content
  • 🎯  Composable useNewzenBlog for easy access
  • 🛠️  CLI tool for database migrations

Quick Setup

Install the module to your Nuxt application with one command:

npx nuxt module add newzen-blog

That's it! You can now use Newzen Blog in your Nuxt app ✨

Configuration

export default defineNuxtConfig({
  modules: ['newzen-blog'],
  newzenBlog: {
    dbPath: './database.sqlite',
    projectMigrationsDir: './drizzle'
  }
})

Usage

Use the useNewzenBlog composable in your components:

const { getAllBlogs } = await useNewzenBlog()

Access getAllBlogs via the API endpoint:

GET /api/blogs

CLI Usage

The module includes a CLI tool for managing database migrations.

Basic Command

Run migrations with default settings:

newzen-blog-migrate

This will:

  1. Generate SQL migration files from the schema
  2. Execute the migrations to update the database
  3. Create a SQLite database at ./blog.db (default location)

Custom Database Path

Specify a custom database file location:

newzen-blog-migrate ./path/to/database.sqlite

Custom Migrations Folder

Specify a custom migrations folder location:

newzen-blog-migrate ./database.sqlite ./drizzle

Full Example

# Create/migrate database in a custom location
newzen-blog-migrate ./data/blog.sqlite ./drizzle

How It Works

Module Workflow Overview

The Newzen Blog module operates in three main phases:

Phase 1: Module Setup (Installation & Configuration)

1. Install module via nuxt module add
   ↓
2. Configure in nuxt.config.ts with dbPath and projectMigrationsDir
   ↓
3. Module registers:
     - Server plugin (initializes database connection)
     - Client plugin  
     - Server handler (/api/blogs endpoint)
     - useNewzenBlog composable

Phase 2: Database Initialization (CLI)

When you run newzen-blog-migrate:

1. Read database schema definition (src/runtime/server/db/schema.ts)
   ↓
2. Compare schema with existing migrations using Drizzle Kit
   ↓
3. Generate new SQL migration files (DDL scripts)
   ↓
4. Connect to SQLite database file
   ↓
5. Execute migrations sequentially
   ↓
6. Track completed migrations in migrations table
   ↓
7. Close database connection safely

Database Schema:

  • blogs table: Stores blog content with id, title, slug, content, and createdAt

Phase 3: Runtime (Your Application)

On Server Side:

1. Database connection pool initialized via server plugin
   ↓
2. When request comes to GET /api/blogs
   ↓
3. Server handler queries all blogs from database
   ↓
4. Returns safe formatted JSON response

On Client Side:

1. Use composable in your component:
   const { getAllBlogs } = useNewzenBlog()
   ↓
2. Call getAllBlogs() to fetch from /api/blogs
   ↓
3. Component receives blog data for rendering

Data Flow Diagram

┌─────────────────────────────────────────────────────────┐
│  Your Nuxt Application                                   │
│  ┌───────────────────────────────────────────────────┐  │
│  │  Component (app.vue)                              │  │
│  │  ├─ useNewzenBlog() → getAllBlogs()              │  │
│  │  └─ Makes HTTP request to /api/blogs             │  │
│  └──────────────────────┬────────────────────────────┘  │
└─────────────────────────┼────────────────────────────────┘
                          │ GET /api/blogs
                          ↓
        ┌─────────────────────────────────┐
        │  Newzen Blog Module             │
        │  ┌─────────────────────────────┐│
        │  │ Server Handler              ││
        │  │ /api/blogs endpoint         ││
        │  └────────────┬────────────────┘│
        └───────────────┼──────────────────┘
                        │ Query
                        ↓
        ┌─────────────────────────────────┐
        │  SQLite Database                │
        │  ┌─────────────────────────────┐│
        │  │ blogs table                 ││
        │  │ (id, title, slug, content)  ││
        │  └─────────────────────────────┘│
        └─────────────────────────────────┘

Key Components

  • Module (src/module.ts): Registers all plugins, handlers, and composables
  • Database (src/runtime/server/db/): Initializes SQLite connection and manages migrations
  • Schema (src/runtime/server/db/schema.ts): Defines blog data structure
  • API Handler (src/runtime/server/api/blogs/index.get.ts): Serves blog data over HTTP
  • Composable (src/runtime/app/composables/useNewzenBlog.ts): Client-side interface for fetching blogs
  • CLI (src/bin/cli.ts): Command-line tool for database setup and migrations

Contribution

# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release