feat: add api keys (#991)
* feat: add api keys * chore: address pull request feedback --------- Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
@@ -20,6 +20,17 @@ import type {
|
||||
WidgetKind,
|
||||
} from "@homarr/definitions";
|
||||
|
||||
export const apiKeys = sqliteTable("apiKey", {
|
||||
id: text("id").notNull().primaryKey(),
|
||||
apiKey: text("apiKey").notNull(),
|
||||
salt: text("salt").notNull(),
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references((): AnySQLiteColumn => users.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
});
|
||||
|
||||
export const users = sqliteTable("user", {
|
||||
id: text("id").notNull().primaryKey(),
|
||||
name: text("name"),
|
||||
@@ -343,6 +354,13 @@ export const serverSettings = sqliteTable("serverSetting", {
|
||||
value: text("value").default('{"json": {}}').notNull(), // empty superjson object
|
||||
});
|
||||
|
||||
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
|
||||
user: one(users, {
|
||||
fields: [apiKeys.userId],
|
||||
references: [users.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const searchEngines = sqliteTable("search_engine", {
|
||||
id: text("id").notNull().primaryKey(),
|
||||
iconUrl: text("icon_url").notNull(),
|
||||
|
||||
Reference in New Issue
Block a user