Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edsol/elysia-drizzle-schema
Elysia.js plugin that helps to use Drizzle ORM schema inside elysia swagger
https://github.com/edsol/elysia-drizzle-schema
bun drizzle drizzle-orm elysia elysiajs swagger
Last synced: 23 days ago
JSON representation
Elysia.js plugin that helps to use Drizzle ORM schema inside elysia swagger
- Host: GitHub
- URL: https://github.com/edsol/elysia-drizzle-schema
- Owner: Edsol
- Created: 2024-02-09T14:01:05.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-12T13:33:54.000Z (9 months ago)
- Last Synced: 2024-10-01T14:53:18.399Z (about 1 month ago)
- Topics: bun, drizzle, drizzle-orm, elysia, elysiajs, swagger
- Language: TypeScript
- Homepage:
- Size: 132 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Elysia Drizzle Schema
Simple [Elysia.js](https://elysiajs.com) plugin that helps to use [Drizzle ORM](https://orm.drizzle.team/) schema inside elysia swagger [model](https://elysiajs.com/validation/reference-model.html#reference-model).
> Only Postgresql (via pg-core) was supported now
## Requirements
- bun
- Drizzle ORM
- Elysia.js## Install
```bash
bun i elysia-drizzle-schema
```
or
```bash
npm i elysia-drizzle-schema
```## Usage
```ts
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(
foo,
{ 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`: list of extra fields to be skipped## Result
It will dynamically load the parameters of the POST body:
![swagger](./docs/images/swagger_example.png)
![swagger](./docs/images/swagger_post_body.png)