feat: update backend schema and code for new profile UI
This commit is contained in:
parent
f800008487
commit
024e30bd99
@ -5,13 +5,7 @@ import { z } from "zod"
|
||||
|
||||
import { and, eq, sql } from "drizzle-orm"
|
||||
import * as schema from "./schema"
|
||||
import {
|
||||
Sandbox,
|
||||
sandbox,
|
||||
sandboxLikes,
|
||||
user,
|
||||
usersToSandboxes,
|
||||
} from "./schema"
|
||||
import { Sandbox, sandbox, user, usersToSandboxes } from "./schema"
|
||||
|
||||
export interface Env {
|
||||
DB: D1Database
|
||||
@ -365,6 +359,16 @@ export default {
|
||||
const updateUserSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string().optional(),
|
||||
bio: z.string().optional(),
|
||||
personalWebsite: z.string().optional(),
|
||||
links: z
|
||||
.array(
|
||||
z.object({
|
||||
url: z.string(),
|
||||
platform: z.enum(schema.KNOWN_PLATFORMS),
|
||||
})
|
||||
)
|
||||
.optional(),
|
||||
email: z.string().email().optional(),
|
||||
username: z.string().optional(),
|
||||
avatarUrl: z.string().optional(),
|
||||
|
@ -2,6 +2,26 @@ import { createId } from "@paralleldrive/cuid2"
|
||||
import { relations, sql } from "drizzle-orm"
|
||||
import { integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core"
|
||||
|
||||
export const KNOWN_PLATFORMS = [
|
||||
"github",
|
||||
"twitter",
|
||||
"instagram",
|
||||
"bluesky",
|
||||
"linkedin",
|
||||
"youtube",
|
||||
"twitch",
|
||||
"discord",
|
||||
"mastodon",
|
||||
"threads",
|
||||
"gitlab",
|
||||
"generic",
|
||||
] as const
|
||||
|
||||
export type KnownPlatform = (typeof KNOWN_PLATFORMS)[number]
|
||||
export type UserLink = {
|
||||
url: string
|
||||
platform: KnownPlatform
|
||||
}
|
||||
// #region Tables
|
||||
export const user = sqliteTable("user", {
|
||||
id: text("id")
|
||||
@ -16,6 +36,9 @@ export const user = sqliteTable("user", {
|
||||
sql`CURRENT_TIMESTAMP`
|
||||
),
|
||||
generations: integer("generations").default(0),
|
||||
bio: text("bio"),
|
||||
personalWebsite: text("personalWebsite"),
|
||||
links: text("links", { mode: "json" }).default("[]").$type<UserLink[]>(),
|
||||
tier: text("tier", { enum: ["FREE", "PRO", "ENTERPRISE"] }).default("FREE"),
|
||||
tierExpiresAt: integer("tierExpiresAt"),
|
||||
lastResetDate: integer("lastResetDate"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user