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

@seedcord/plugin-kysely-postgres

v0.4.2

Published

Connect a seedcord bot to Postgres with Kysely

Downloads

1,325

Readme

npm node license

About

@seedcord/plugin-kysely-postgres connects a seedcord bot to Postgres through Kysely. It opens the pool during startup, runs your migrations, loads every class under dir that carries @RegisterKyselyService, and exposes them under the key you attached it on.

You declare the schema once. Kysely types every query off it, so a renamed column breaks the build.

It runs on the gateway transport and on http's server runtime. Attaching it to an edge host is a compile error.

Until v1.0.0, minor versions can break.

Installation

pnpm add @seedcord/plugin-kysely-postgres kysely pg

kysely, pg, envapt, typescript, and @seedcord/core are peer dependencies.

Attach

attach takes a property name, the plugin class, and its options. Chain it off the constructor:

// bot.ts
import { resolve } from 'node:path';

import { Seedcord } from '@seedcord/gateway';
import { KyselyPostgres } from '@seedcord/plugin-kysely-postgres';

export const seedcord = new Seedcord(config).attach('sql', KyselyPostgres, {
    dir: resolve(import.meta.dirname, './services'),
    connectionString: Vars.databaseUrl,
    migrations: { path: resolve(import.meta.dirname, './migrations') }
});

export default seedcord;
// index.ts
import seedcord from './bot';

await seedcord.start();

attach returns the instance widened with the key, and seedcord codegen writes sql: (typeof Bot)['sql'] into seedcord-gen.d.ts off a default import of that module. Calling attach as a bare statement drops the widened type. A named-only export leaves codegen with nothing to import.

Attach before startup. A call after initialization throws CorePluginAfterInit.

Vars.databaseUrl stands in for an envapt accessor. process.env.DATABASE_URL types as string | undefined, which connectionString?: string rejects under the exactOptionalPropertyTypes that @seedcord/tsconfig turns on.

migrations.onStartup runs to latest by default.

Schema

Declare it once so every service and the plugin's own connection resolve table names from it:

declare module '@seedcord/plugin-kysely-postgres' {
    interface KyselyDatabase {
        schema: MyDatabase;
    }
}

Until that declaration exists, KyselyTable widens to string and any table name type-checks.

Services

The key names the table, and table overrides it when the two differ:

import { KyselyService, RegisterKyselyService } from '@seedcord/plugin-kysely-postgres';

@RegisterKyselyService('users', { table: 'app_users' })
export class UsersService extends KyselyService<'app_users'> {
    public async findByUserId(userId: string) {
        return this.db.selectFrom(this.table).selectAll().where('user_id', '=', userId).executeTakeFirst();
    }
}

Name each key once so the lookup types resolve:

declare module '@seedcord/plugin-kysely-postgres' {
    interface KyselyServices {
        users: UsersService;
    }
}

Then call it from a handler through core:

const user = await this.core.sql.services.users.findByUserId(this.event.user.id);