🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

elysia-drizzle-schema

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elysia-drizzle-schema

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

1.0.11
latest
Source
npm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

bun

FAQs

Package last updated on 12 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts