Skip to content

Commit

Permalink
Merge pull request #1882 from undb-io/release/v1.0.0-13
Browse files Browse the repository at this point in the history
Release version v1.0.0-13
  • Loading branch information
nichenqin authored Aug 16, 2024
2 parents f2d4d96 + a11becd commit edea673
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 6 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog


## v1.0.0-13


### 🏡 Chore

- Openapi swagger ([243cbd2](https://github.com/undb-io/undb/commit/243cbd2))

### ❤️ Contributors

- Nichenqin ([@nichenqin](http://github.com/nichenqin))

## v1.0.0-12


Expand Down
17 changes: 16 additions & 1 deletion apps/backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { WebhookEventsHandler } from "@undb/webhook"
import { Elysia } from "elysia"
import { all } from "radash"
import { v4 } from "uuid"
import * as pkg from "../../../package.json"
import { Auth, OpenAPI, Realtime, SpaceModule, TableModule, Web } from "./modules"
import { FileService } from "./modules/file/file"
import { OpenTelemetryModule } from "./modules/opentelemetry/opentelemetry.module"
Expand Down Expand Up @@ -103,7 +104,21 @@ export const app = new Elysia()
})
.use(cors())
.use(html())
.use(swagger())
.use(
swagger({
path: "/openapi",
excludeStaticFile: true,
exclude: new RegExp(/^(?!.*\/api\/bases).*/),
documentation: {
info: {
title: "Undb OpenAPI Documentation",
version: pkg.version,
},

tags: [{ name: "Record", description: "Record operations" }],
},
}),
)
.derive(auth.store())
.onError((ctx) => {
ctx.logger.error(ctx.error)
Expand Down
71 changes: 67 additions & 4 deletions apps/backend/src/modules/openapi/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ export class OpenAPI {
},
{
params: t.Object({ baseName: t.String(), tableName: t.String() }),
detail: {
tags: ["Doc"],
summary: "Get OpenAPI documentation for a table",
description: "Get OpenAPI documentation for a table",
},
},
)
.group("/records", (app) => {
Expand Down Expand Up @@ -156,7 +161,14 @@ export class OpenAPI {
records: result.values,
}
},
{ params: t.Object({ baseName: t.String(), tableName: t.String() }) },
{
params: t.Object({ baseName: t.String(), tableName: t.String() }),
detail: {
tags: ["Record"],
summary: "Get records",
description: "Get records",
},
},
)
.get(
"/:recordId",
Expand All @@ -169,7 +181,14 @@ export class OpenAPI {
data: result,
}
},
{ params: t.Object({ baseName: t.String(), tableName: t.String(), recordId: t.String() }) },
{
params: t.Object({ baseName: t.String(), tableName: t.String(), recordId: t.String() }),
detail: {
tags: ["Record"],
summary: "Get record by id",
description: "Get record by id",
},
},
)
.post(
"/",
Expand All @@ -182,6 +201,11 @@ export class OpenAPI {
{
params: t.Object({ baseName: t.String(), tableName: t.String() }),
body: t.Object({ values: t.Record(t.String(), t.Any()) }),
detail: {
tags: ["Record"],
summary: "Create record",
description: "Create record",
},
},
)
.post(
Expand All @@ -195,6 +219,11 @@ export class OpenAPI {
{
params: t.Object({ baseName: t.String(), tableName: t.String() }),
body: t.Object({ records: t.Array(t.Object({ id: t.Optional(t.String()), values: t.Any() })) }),
detail: {
tags: ["Record"],
summary: "Create records",
description: "Create records",
},
},
)
.patch(
Expand All @@ -215,6 +244,11 @@ export class OpenAPI {
{
params: t.Object({ baseName: t.String(), tableName: t.String(), recordId: t.String() }),
body: t.Object({ values: t.Record(t.String(), t.Any()) }),
detail: {
tags: ["Record"],
summary: "Update record by id",
description: "Update record by id",
},
},
)
.patch(
Expand All @@ -239,6 +273,11 @@ export class OpenAPI {
filter: t.Any(),
values: t.Record(t.String(), t.Any()),
}),
detail: {
tags: ["Record"],
summary: "Update records",
description: "Update records",
},
},
)
.post(
Expand All @@ -249,7 +288,14 @@ export class OpenAPI {
this.commandBus.execute(new DuplicateRecordCommand({ baseName, tableName, id: ctx.params.recordId })),
)
},
{ params: t.Object({ baseName: t.String(), tableName: t.String(), recordId: t.String() }) },
{
params: t.Object({ baseName: t.String(), tableName: t.String(), recordId: t.String() }),
detail: {
tags: ["Record"],
summary: "Duplicate record by id",
description: "Duplicate record by id",
},
},
)
.post(
"/records/duplicate",
Expand All @@ -269,6 +315,11 @@ export class OpenAPI {
{
params: t.Object({ baseName: t.String(), tableName: t.String() }),
body: t.Object({ filter: t.Any() }),
detail: {
tags: ["Record"],
summary: "Duplicate records",
description: "Duplicate records",
},
},
)
.delete(
Expand All @@ -279,7 +330,14 @@ export class OpenAPI {
this.commandBus.execute(new DeleteRecordCommand({ baseName, tableName, id: ctx.params.recordId })),
)
},
{ params: t.Object({ baseName: t.String(), tableName: t.String(), recordId: t.String() }) },
{
params: t.Object({ baseName: t.String(), tableName: t.String(), recordId: t.String() }),
detail: {
tags: ["Record"],
summary: "Delete record by id",
description: "Delete record by id",
},
},
)
.delete(
"/",
Expand All @@ -299,6 +357,11 @@ export class OpenAPI {
{
params: t.Object({ baseName: t.String(), tableName: t.String() }),
body: t.Object({ filter: t.Any() }),
detail: {
tags: ["Record"],
summary: "Delete records",
description: "Delete records",
},
},
)
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "undb",
"version": "1.0.0-12",
"version": "1.0.0-13",
"private": true,
"scripts": {
"build": "NODE_ENV=production bun --bun turbo build",
Expand Down

0 comments on commit edea673

Please sign in to comment.