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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tsdiapi/dboptions

v0.4.3

Published

A TSDIAPI plugin that extends API functionality by adding a key management system and a convenient API for retrieving and saving configuration options in a database.

Readme

@tsdiapi/dboptions: Database Options Plugin for TSDIAPI-Server

@tsdiapi/dboptions extends TSDIAPI-Server with dynamic database options, integrating seamlessly with Prisma. It enables storing and managing configuration settings in a database with optional TSchema transformation and authentication control.


Features

  • Prisma Integration: Automatically adds a DbOption model for storing key-value configurations.
  • Dynamic API Routes: Provides endpoints for managing database options.
  • TSchema Support: Optionally transform database-stored values using a TSchema.
  • JWT Authentication: Secure access using a custom adminGuard function.
  • Auto-Registration: Automatically integrates controllers when enabled.
  • Feature Generator: Allows custom entity names for full control over the setup.

Installation

npm install @tsdiapi/dboptions

Or use the CLI to add the plugin:

tsdiapi plugins add dboptions

Usage

Register the Plugin

Add the plugin to your TSDIAPI-Server setup:

import { createApp } from "@tsdiapi/server";
import DboptionsPlugin from "@tsdiapi/dboptions";
import TsdiapiPrismaPlugin from "@tsdiapi/prisma";
import { isJWTValid } from "@tsdiapi/jwt-auth";
import { AppSchema } from "./dboptions.config";

createApp({
  plugins: [
    DboptionsPlugin({
      tSchema: AppSchema, // TypeBox schema for TSchema transformations
      adminGuard: async (req) => {
        const session = await isJWTValid<any>(req);
        if (!session) {
          return false;
        }
        return session.isAdmin; // Allow only admins
      },
    }),
    TsdiapiPrismaPlugin(),
  ],
});

Configuration Options

| Option | Type | Default | Description | | ------------ | ---------- | ------- | -------------------------------------------------- | | tSchema | TObject | null | TypeBox schema for transformations. | | adminGuard | Function | null | Custom function to validate Bearer authentication. |


Auto-Registration

If DBOPTIONS_AUTO_REGISTER_CONTROLLERS is enabled, the plugin:

  • Adds the DbOption model to Prisma schema.
  • Automatically registers API controllers for managing options.

To disable auto-registration, use:

{
  "DBOPTIONS_AUTO_REGISTER_CONTROLLERS": false
}

For manual setup, use the feature generator to create a custom entity:

tsdiapi generate dboptions feature

This allows defining a custom database model and gaining full control over API behavior.


Summary

The @tsdiapi/dboptions plugin extends TSDIAPI with a database-driven configuration system. It supports Prisma, TSchema-based transformations, and flexible authentication control. Use auto-registration for quick setup or manual generation for advanced customization. 🚀