mirror of
https://github.com/nestriness/nestri.git
synced 2026-08-02 01:35:18 +03:00
feat: Add sdk openapi generators
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { teamTable } from "../team/team.sql.js";
|
||||
import { userTable } from "../user/user.sql.js";
|
||||
import { pgTable, varchar } from "drizzle-orm/pg-core";
|
||||
import { id, timestamps, ulid } from "../drizzle/types.js";
|
||||
|
||||
@@ -8,8 +8,8 @@ export const apiAppTable = pgTable("api_app", {
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
secret: varchar("secret", { length: 255 }).notNull(),
|
||||
redirectURI: varchar("redirect", { length: 255 }).notNull(),
|
||||
teamID: ulid("team_id")
|
||||
.references(() => teamTable.id, {
|
||||
ownerID: ulid("owner_id")
|
||||
.references(() => userTable.id, {
|
||||
onDelete: "cascade",
|
||||
})
|
||||
.notNull(),
|
||||
@@ -19,8 +19,8 @@ export const apiPersonalTokenTable = pgTable("api_personal_token", {
|
||||
...id,
|
||||
...timestamps,
|
||||
token: varchar("token", { length: 255 }).notNull(),
|
||||
teamID: ulid("team_id")
|
||||
.references(() => teamTable.id, {
|
||||
ownerID: ulid("owner_id")
|
||||
.references(() => userTable.id, {
|
||||
onDelete: "cascade",
|
||||
})
|
||||
.notNull(),
|
||||
|
||||
@@ -36,7 +36,7 @@ export namespace Personal {
|
||||
return tx
|
||||
.select({
|
||||
id: apiPersonalTokenTable.id,
|
||||
teamID: apiPersonalTokenTable.teamID,
|
||||
ownerID: apiPersonalTokenTable.ownerID,
|
||||
})
|
||||
.from(apiPersonalTokenTable)
|
||||
.where(eq(apiPersonalTokenTable.token, token))
|
||||
|
||||
@@ -6,11 +6,13 @@ import { PostgresJsQueryResultHKT, drizzle } from "drizzle-orm/postgres-js";
|
||||
|
||||
export namespace Database {
|
||||
const { DATABASE_URL } = process.env;
|
||||
if (!DATABASE_URL) {
|
||||
throw new Error("DATABASE_URL is not set");
|
||||
}
|
||||
// if (!DATABASE_URL) {
|
||||
// throw new Error("DATABASE_URL is not set");
|
||||
// }
|
||||
const dbUrl =
|
||||
DATABASE_URL || "postgres://user:password@localhost:5432/nestri";
|
||||
|
||||
const sql = postgres(DATABASE_URL, {
|
||||
const sql = postgres(dbUrl, {
|
||||
max: 20,
|
||||
idle_timeout: 60,
|
||||
});
|
||||
|
||||
11
packages/core/src/utils/lazy.ts
Normal file
11
packages/core/src/utils/lazy.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function lazy<T>(fn: () => T) {
|
||||
let value: T | undefined;
|
||||
let loaded = false;
|
||||
|
||||
return (): T => {
|
||||
if (loaded) return value as T;
|
||||
loaded = true;
|
||||
value = fn();
|
||||
return value as T;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user