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

@tripod311/zy_cms

v1.1.2

Published

Simple cms for simple services and websites

Readme

ZY CMS

CMS engine for Node.js. Name can be interpreted as laZY/eaZY CMS.

Once upon a time I had to make 3 similar services (database + file storage + admin panel + API) in one month. I don't want to do it again, so I created this.


📚 Table of Contents


Installation

Simply run:

npm install @tripod311/zy_cms

Configuration

Here's an example configuration file:

admin_panel: true
storage:
  enable: true
  path: "./data/media"
  publicGET: true
db:
  type: "postgres"
  path: "./data/db.sqlite"
  host: "localhost"
  port: 5432
  user: "tripod"
  password: "1234"
  database: "test"
http:
  cookie_secret: "cookie_secret"
  port: 8080
  credentials:
    key: "path-to-key"
    cert: "path-to-cert"
    ca: "path-to-ca"
  cors:
    origin:
      - "http://localhost:8080"
    methods:
      - GET
      - POST
      - PUT
      - DELETE
auth:
  enable: true
  jwt_secret: "jwt_secret"
  secure_cookies: false
localization:
  enable: true
  locales: ["ru", "en"]
  fallbackLocale: "en"

Explanation of fields:

  • admin_panel – toggle default admin panel

  • storage – file storage options

    • enable – toggle file storage
    • path – path to where files will be stored
    • publicGET – if true, /storage/:alias can be accessed without authorization
  • db – supports sqlite, mysql, and postgres

    • path – only for sqlite
    • other options apply to mysql/postgres
  • http – webserver settings

    • cookie_secret – optional
    • port – port to listen on
    • credentials – set to null for http mode
    • cors – CORS rules
  • auth – authorization system

    • must be enabled if using admin panel
  • localization – currently affects only localized fields in schema

Put this config into config.yaml in the project root.


Database schema

Example schema.yaml:

tables:
  - name: pages
    fields:
    - name: name
      type: "VARCHAR(300)"
      required: true
      unique: true
    - name: content
      type: "json"
      distinct_type: "TEXT"
      required: true
      localized: true
    - name: content
      type: "markdown"
      distinct_type: "TEXT"
      required: true
      localized: true
    - name: switch
      type: "BOOLEAN"
      required: false
    - name: text
      type: "TEXT"
    - name: date
      type: "datetime"
    - name: author
      type: "VARCHAR(255)"
      relation:
        table: "users"
        column: "login"
        kind: many-to-one
        onDelete: setNull
    - name: some_media
      type: "VARCHAR(255)"
      relation:
        table: "media"
        column: "alias"
        kind: one-to-one
        onDelete: setNull
  • tables is a list of table definitions

  • each field has:

    • name – column name
    • type – SQL or CMS-specific
    • distinct_type – enforced SQL type for CMS types
    • required – like NOT NULL
    • localized – creates per-locale columns
    • relation – SQL-like foreign key

ZY CMS types

CMS-specific types:

  • json – stored as LONGTEXT or equivalent
  • markdown – stored as LONGTEXT
  • datetime – stored as ISO string (VARCHAR(30))

For PostgreSQL: you must specify distinct_type, since PostgreSQL doesn’t have LONGTEXT

Relations

Analogous to SQL REFERENCES. Requires:

  • table and column
  • kind: one-to-one or many-to-one
  • onDelete: cascade, setNull, restrict, noAction, setDefault

Many-to-many must be modeled manually with intermediate tables

Basic tables

If auth is enabled, a users table is created with:

  • id, login, password
  • password is stored as bcrypt hash in CHAR(60)

If storage is enabled, a media table is created with:

  • id, alias, path

First start

Create an empty file called firstLaunch in your project root. This allows creating the first user in admin panel.

Example:

import path from "path";
import Application from "@tripod311/zy_cms";
import FastifyStatic from "@fastify/static";

const app = new Application();

async function start () {
  await app.setup();
  await app.start();
}

function stop () {
  (async () => {
    await app.stop();
  })();
}

process.on("SIGINT", stop);
process.on("SIGTERM", stop);

start();

Admin panel will be available at /admin/.


API overview

DB

app.db.create<T>(tableName: string, data: Partial<T>): Promise<void>
app.db.read<T>(tableName: string, options: ReadOptions<T>): Promise<T>
app.db.update<T>(tableName: string, data: Partial<T>, options: UpdateOptions<T>): Promise<void>
app.db.delete<T>(tableName: string, options: DeleteOptions<T>): Promise<void>

Auth

app.auth.create(login: string, password: string): Promise<void>
app.auth.delete(login: string): Promise<void>

Middlewares:

app.auth.forceAuth(request, reply) // restricts to logged-in users
app.auth.checkAuth(request, reply) // optional login (request.user?.login)

Route handler:

app.auth.authorize(request, reply) // expects JSON { login, password }, sets cookie

Storage

app.storage.create(file: StorageFile): Promise<void>
app.storage.read(file: StorageFile): Promise<string>
app.storage.update(file: StorageFile): Promise<void>
app.storage.delete(file: StorageFile): Promise<void>

Type reference

StorageFile

interface StorageFile {
  id?: number;
  alias: string;
  extension?: string;
  path?: string;
  content?: Buffer;
}

ReadOptions

interface ReadOptions<T> {
  where?: Partial<T> | WhereFilter<T>;
  fields?: (keyof T)[];
  orderBy?: keyof T | `${keyof T & string} ASC` | `${keyof T & string} DESC`;
  limit?: number;
  offset?: number;
}

UpdateOptions

interface UpdateOptions<T> {
  returning?: boolean;
  where?: Partial<T> | WhereFilter<T>;
}

Feel free to open an issue or PR if you’d like to contribute or request a feature ✨