Skip to content

Elysia.js plugin that helps to use Drizzle ORM schema inside elysia swagger

Notifications You must be signed in to change notification settings

Edsol/elysia-drizzle-schema

Repository files navigation

Elysia Drizzle Schema

Simple Elysia.js plugin that helps to use Drizzle ORM schema inside elysia swagger model.

Only Postgresql (via pg-core) was supported now

Requirements

  • bun
  • Drizzle ORM
  • Elysia.js

Install

bun i elysia-drizzle-schema

or

npm i elysia-drizzle-schema

Usage

import { foo } from "../db/schema";
import { parseDrizzleModel, type optionsParams } from "./elysia-drizzle";
import type { PgTable } from "drizzle-orm/pg-core";

const app = new Elysia();

app
  .use(swagger())
  .model({
    foo: parseDrizzleModel(
      <PgTable>foo,
      <optionsParams>{ exludedColumns: ["id", "uuid"] }
    ),
  })
  .put("/", requestController.insert, {
    body: "test",
    detail: {
      summary: "Insert new entity",
    },
  })
  .listener(3000);

Defaults

optionsParams defines the default settings. The accepted parameters are:

  • excludePrimaryKey: boolean: to programmatically skip the id field
  • excludedColumns?: Array<string>: list of extra fields to be skipped

Result

It will dynamically load the parameters of the POST body:

swagger swagger

About

Elysia.js plugin that helps to use Drizzle ORM schema inside elysia swagger

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published