feat: Modify apikeys schema and README configuration files

This commit is contained in:
beilunyang
2025-03-09 11:07:21 +08:00
parent c405c02a34
commit 994ab8acc3
2 changed files with 15 additions and 13 deletions

View File

@@ -87,9 +87,9 @@ pnpm install
3. 设置 wrangler
```bash
cp wrangler.example.toml wrangler.toml
cp wrangler.email.example.toml wrangler.email.toml
cp wrangler.cleanup.example.toml wrangler.cleanup.toml
cp wrangler.example.json wrangler.json
cp wrangler.email.example.json wrangler.email.json
cp wrangler.cleanup.example.json wrangler.cleanup.json
```
设置 Cloudflare D1 数据库名以及数据库 ID
@@ -441,17 +441,17 @@ const data = await res.json();
## 交流
<table>
<tr>
<td style="max-width: 360px">
<img src="https://pic.otaku.ren/20250309/AQADAcQxGxQjaVZ-.jpg" width="300" />
<tr style="max-width: 360px">
<td>
<img src="https://pic.otaku.ren/20250309/AQADAcQxGxQjaVZ-.jpg" />
</td>
<td style="max-width: 360px">
<img src="https://pic.otaku.ren/20250309/AQADCMQxGxQjaVZ-.jpg" width="300" />
<td>
<img src="https://pic.otaku.ren/20250309/AQADCMQxGxQjaVZ-.jpg" />
</td>
</tr>
<tr>
<tr style="max-width: 360px">
<td>
关注公众号了解更多项目进展以及AI, 区块链,独立开发资讯
关注公众号了解更多项目进展以及AI区块链,独立开发资讯
</td>
<td>
添加微信,备注 "MoeMail" 拉你进微信交流群

View File

@@ -1,4 +1,4 @@
import { integer, sqliteTable, text, primaryKey } from "drizzle-orm/sqlite-core"
import { integer, sqliteTable, text, primaryKey, uniqueIndex } from "drizzle-orm/sqlite-core"
import type { AdapterAccountType } from "next-auth/adapters"
import { relations } from 'drizzle-orm';
@@ -96,12 +96,14 @@ export const userRoles = sqliteTable("user_role", {
export const apiKeys = sqliteTable('api_keys', {
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
userId: text('user_id').notNull().references(() => users.id),
name: text('name').notNull().unique(),
name: text('name').notNull(),
key: text('key').notNull().unique(),
createdAt: integer('created_at', { mode: 'timestamp' }).$defaultFn(() => new Date()),
expiresAt: integer('expires_at', { mode: 'timestamp' }),
enabled: integer('enabled', { mode: 'boolean' }).notNull().default(true),
});
}, (table) => ({
nameUserIdUnique: uniqueIndex('name_user_id_unique').on(table.name, table.userId)
}));
export const apiKeysRelations = relations(apiKeys, ({ one }) => ({
user: one(users, {