@percepta/create 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -0
- package/dist/chunk-GEVZERMP.js +108 -0
- package/dist/chunk-R4FWPE4A.js +49 -0
- package/dist/chunk-WMJT7CB5.js +57 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +974 -0
- package/dist/init-Z4VGBHAK.js +96 -0
- package/dist/status-MITGDLTT.js +76 -0
- package/dist/sync-J4SFZHDX.js +136 -0
- package/dist/upstream-AQI7P4EU.js +144 -0
- package/package.json +58 -0
- package/template-versions.json +4 -0
- package/templates/library/README.md +30 -0
- package/templates/library/eslint.config.js +10 -0
- package/templates/library/gitignore.template +18 -0
- package/templates/library/package.json.template +29 -0
- package/templates/library/src/index.ts +9 -0
- package/templates/library/tsconfig.json +19 -0
- package/templates/monorepo/README.md +41 -0
- package/templates/monorepo/eslint.config.js +10 -0
- package/templates/monorepo/gitignore.template +31 -0
- package/templates/monorepo/npmrc.template +4 -0
- package/templates/monorepo/package.json.template +25 -0
- package/templates/monorepo/packages/.gitkeep +0 -0
- package/templates/monorepo/pnpm-workspace.yaml +2 -0
- package/templates/monorepo/tsconfig.json +16 -0
- package/templates/webapp/.claude/commands/sync.md +19 -0
- package/templates/webapp/.claude/commands/upstream.md +17 -0
- package/templates/webapp/.dockerignore +59 -0
- package/templates/webapp/.gitattributes +1 -0
- package/templates/webapp/.github/workflows/__APP_NAME__-ryvn-release.yaml +114 -0
- package/templates/webapp/.github/workflows/__APP_NAME__-terraform.yml +28 -0
- package/templates/webapp/.github/workflows/ci.yml +149 -0
- package/templates/webapp/.node-version +2 -0
- package/templates/webapp/.prettierrc.mjs +5 -0
- package/templates/webapp/AGENTS.md +240 -0
- package/templates/webapp/Dockerfile +64 -0
- package/templates/webapp/README.md +200 -0
- package/templates/webapp/agent-skills/database.md +140 -0
- package/templates/webapp/agent-skills/deploy.md +94 -0
- package/templates/webapp/agent-skills/inngest.md +147 -0
- package/templates/webapp/agent-skills/langfuse.md +117 -0
- package/templates/webapp/agent-skills/oneshot.md +216 -0
- package/templates/webapp/agent-skills/ryvn.md +25 -0
- package/templates/webapp/deploy/README.md +39 -0
- package/templates/webapp/deploy/ryvn/__APP_NAME__.service.yaml +11 -0
- package/templates/webapp/deploy/ryvn/environments/percepta-test/installations/__APP_NAME__.env.percepta-test.serviceinstallation.yaml +121 -0
- package/templates/webapp/docker-compose.yml +19 -0
- package/templates/webapp/drizzle.config.ts +30 -0
- package/templates/webapp/env.example.template +44 -0
- package/templates/webapp/eslint.config.mjs +52 -0
- package/templates/webapp/gitignore.template +53 -0
- package/templates/webapp/next.config.ts +8 -0
- package/templates/webapp/npmrc.template +4 -0
- package/templates/webapp/package.json.template +122 -0
- package/templates/webapp/postcss.config.mjs +5 -0
- package/templates/webapp/scripts/create-user.ts +47 -0
- package/templates/webapp/scripts/migrate.ts +18 -0
- package/templates/webapp/scripts/seed.ts +62 -0
- package/templates/webapp/scripts/setup-database.ts +57 -0
- package/templates/webapp/scripts/setup-readonly-user.ts +193 -0
- package/templates/webapp/scripts/start.sh +52 -0
- package/templates/webapp/src/app/(app)/layout.tsx +21 -0
- package/templates/webapp/src/app/(app)/page.tsx +30 -0
- package/templates/webapp/src/app/(auth)/auth/signin/CredentialsSignInForm.tsx +103 -0
- package/templates/webapp/src/app/(auth)/auth/signin/page.tsx +30 -0
- package/templates/webapp/src/app/(auth)/layout.tsx +15 -0
- package/templates/webapp/src/app/api/auth/[...all]/route.ts +4 -0
- package/templates/webapp/src/app/api/healthz/route.ts +10 -0
- package/templates/webapp/src/app/api/inngest/route.ts +31 -0
- package/templates/webapp/src/app/api/readyz/route.ts +31 -0
- package/templates/webapp/src/app/api/trpc/[trpc]/route.ts +21 -0
- package/templates/webapp/src/app/favicon.ico +0 -0
- package/templates/webapp/src/app/global-error.tsx +27 -0
- package/templates/webapp/src/app/layout.tsx +18 -0
- package/templates/webapp/src/components/FaroProvider.tsx +37 -0
- package/templates/webapp/src/components/Header.tsx +70 -0
- package/templates/webapp/src/components/Providers.tsx +45 -0
- package/templates/webapp/src/components/form/FormItem.tsx +82 -0
- package/templates/webapp/src/config/clientEnvConfig.ts +11 -0
- package/templates/webapp/src/config/getEnvConfig.ts +62 -0
- package/templates/webapp/src/config/isDev.ts +7 -0
- package/templates/webapp/src/drizzle/db.ts +28 -0
- package/templates/webapp/src/drizzle/migrations/0000_eager_grandmaster.sql +57 -0
- package/templates/webapp/src/drizzle/migrations/meta/0000_snapshot.json +376 -0
- package/templates/webapp/src/drizzle/migrations/meta/_journal.json +13 -0
- package/templates/webapp/src/drizzle/schema/auth/accounts.ts +33 -0
- package/templates/webapp/src/drizzle/schema/auth/sessions.ts +25 -0
- package/templates/webapp/src/drizzle/schema/auth/users.ts +38 -0
- package/templates/webapp/src/drizzle/schema/auth/verifications.ts +19 -0
- package/templates/webapp/src/drizzle/schema/index.ts +4 -0
- package/templates/webapp/src/drizzle/schema/utils/jsonbFromZod.ts +25 -0
- package/templates/webapp/src/instrumentation.ts +35 -0
- package/templates/webapp/src/lib/auth/index.ts +85 -0
- package/templates/webapp/src/lib/auth-client.ts +6 -0
- package/templates/webapp/src/lib/trpc.ts +15 -0
- package/templates/webapp/src/server/api/root.ts +5 -0
- package/templates/webapp/src/server/trpc.ts +61 -0
- package/templates/webapp/src/services/AuthContextService.ts +63 -0
- package/templates/webapp/src/services/DatabaseService.ts +54 -0
- package/templates/webapp/src/services/inngest/InngestFunctionCollection.ts +5 -0
- package/templates/webapp/src/services/inngest/InngestService.ts +71 -0
- package/templates/webapp/src/services/inngest/events/AppEvents.ts +34 -0
- package/templates/webapp/src/services/inngest/events/payloads/ExampleEventPayload.ts +14 -0
- package/templates/webapp/src/services/langfuse/LangfuseService.ts +80 -0
- package/templates/webapp/src/services/logger/AppLogger.ts +61 -0
- package/templates/webapp/src/services/logger/withRequestContext.ts +27 -0
- package/templates/webapp/src/services/observability/initFaro.ts +22 -0
- package/templates/webapp/src/startup-checks.ts +32 -0
- package/templates/webapp/src/styles/globals.css +27 -0
- package/templates/webapp/src/utils/__tests__/cn.test.ts +20 -0
- package/templates/webapp/src/utils/cn.ts +6 -0
- package/templates/webapp/src/utils/syncInngestApp.ts +62 -0
- package/templates/webapp/terraform/README.md +147 -0
- package/templates/webapp/terraform/deploy.sh +97 -0
- package/templates/webapp/terraform/main.tf +101 -0
- package/templates/webapp/terraform/modules/cloudtrail/main.tf +27 -0
- package/templates/webapp/terraform/modules/cloudtrail/outputs.tf +10 -0
- package/templates/webapp/terraform/modules/cloudtrail/variables.tf +15 -0
- package/templates/webapp/terraform/modules/networking/main.tf +118 -0
- package/templates/webapp/terraform/modules/networking/outputs.tf +38 -0
- package/templates/webapp/terraform/modules/networking/variables.tf +24 -0
- package/templates/webapp/terraform/modules/rds/main.tf +227 -0
- package/templates/webapp/terraform/modules/rds/outputs.tf +73 -0
- package/templates/webapp/terraform/modules/rds/variables.tf +61 -0
- package/templates/webapp/terraform/modules/s3-logging/main.tf +148 -0
- package/templates/webapp/terraform/modules/s3-logging/outputs.tf +10 -0
- package/templates/webapp/terraform/modules/s3-logging/variables.tf +16 -0
- package/templates/webapp/terraform/modules/secrets/main.tf +39 -0
- package/templates/webapp/terraform/modules/secrets/outputs.tf +9 -0
- package/templates/webapp/terraform/modules/secrets/variables.tf +51 -0
- package/templates/webapp/terraform/outputs.tf +102 -0
- package/templates/webapp/terraform/providers.tf +32 -0
- package/templates/webapp/terraform/terraform.tfvars.example +65 -0
- package/templates/webapp/terraform/variables.tf +129 -0
- package/templates/webapp/tsconfig.json +14 -0
- package/templates/webapp/vitest.config.ts +9 -0
- package/templates/webapp/vitest.setup.ts +5 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DropdownMenu,
|
|
5
|
+
DropdownMenuContent,
|
|
6
|
+
DropdownMenuItem,
|
|
7
|
+
DropdownMenuLabel,
|
|
8
|
+
DropdownMenuSeparator,
|
|
9
|
+
DropdownMenuTrigger,
|
|
10
|
+
} from "@percepta/design";
|
|
11
|
+
import { LogOut } from "lucide-react";
|
|
12
|
+
import React, { useCallback } from "react";
|
|
13
|
+
import { authClient } from "../lib/auth-client";
|
|
14
|
+
|
|
15
|
+
export default function Header() {
|
|
16
|
+
const { data: session } = authClient.useSession();
|
|
17
|
+
const user = session?.user;
|
|
18
|
+
|
|
19
|
+
const handleSignOut = useCallback(() => {
|
|
20
|
+
void authClient.signOut({
|
|
21
|
+
fetchOptions: {
|
|
22
|
+
onSuccess: () => {
|
|
23
|
+
window.location.href = "/auth/signin";
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
if (!user) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<header className="sticky top-0 z-30 flex h-16 w-full items-center justify-end border-b border-border bg-card px-4 shadow-sm sm:px-6 lg:px-8">
|
|
35
|
+
<DropdownMenu>
|
|
36
|
+
<DropdownMenuTrigger asChild={true}>
|
|
37
|
+
<button
|
|
38
|
+
className="-mx-2 flex items-center gap-3 rounded-lg px-2 py-1 transition-colors hover:bg-muted"
|
|
39
|
+
aria-label="Open account menu"
|
|
40
|
+
>
|
|
41
|
+
<div className="hidden text-right sm:block">
|
|
42
|
+
<p className="text-sm font-medium text-foreground">
|
|
43
|
+
{user.name || "User"}
|
|
44
|
+
</p>
|
|
45
|
+
<p className="text-xs text-muted-foreground">{user.email}</p>
|
|
46
|
+
</div>
|
|
47
|
+
<div className="flex h-9 w-9 items-center justify-center rounded-full border border-border bg-primary/10 text-sm font-semibold text-primary">
|
|
48
|
+
{(user.name || user.email || "U").slice(0, 1).toUpperCase()}
|
|
49
|
+
</div>
|
|
50
|
+
</button>
|
|
51
|
+
</DropdownMenuTrigger>
|
|
52
|
+
<DropdownMenuContent align="end" sideOffset={8}>
|
|
53
|
+
<DropdownMenuLabel>
|
|
54
|
+
<div>
|
|
55
|
+
<p className="text-sm font-medium">{user.name || "User"}</p>
|
|
56
|
+
<p className="text-xs font-normal text-muted-foreground">
|
|
57
|
+
{user.email}
|
|
58
|
+
</p>
|
|
59
|
+
</div>
|
|
60
|
+
</DropdownMenuLabel>
|
|
61
|
+
<DropdownMenuSeparator />
|
|
62
|
+
<DropdownMenuItem onClick={handleSignOut}>
|
|
63
|
+
<LogOut />
|
|
64
|
+
Sign Out
|
|
65
|
+
</DropdownMenuItem>
|
|
66
|
+
</DropdownMenuContent>
|
|
67
|
+
</DropdownMenu>
|
|
68
|
+
</header>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Toaster } from "@percepta/design";
|
|
4
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { TRPCProvider, trpcClient } from "../lib/trpc";
|
|
7
|
+
import { AppFaroProvider } from "./FaroProvider";
|
|
8
|
+
|
|
9
|
+
export const Providers: React.FC<React.PropsWithChildren> = ({ children }) => {
|
|
10
|
+
const queryClient = getQueryClient();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<AppFaroProvider>
|
|
14
|
+
<QueryClientProvider client={queryClient}>
|
|
15
|
+
<TRPCProvider trpcClient={trpcClient} queryClient={queryClient}>
|
|
16
|
+
{children}
|
|
17
|
+
<Toaster />
|
|
18
|
+
</TRPCProvider>
|
|
19
|
+
</QueryClientProvider>
|
|
20
|
+
</AppFaroProvider>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
let browserQueryClient: QueryClient | undefined;
|
|
25
|
+
function getQueryClient(): QueryClient {
|
|
26
|
+
if (typeof window === "undefined") {
|
|
27
|
+
// Always make a new server query client.
|
|
28
|
+
return makeQueryClient();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (browserQueryClient == null) {
|
|
32
|
+
browserQueryClient = makeQueryClient();
|
|
33
|
+
}
|
|
34
|
+
return browserQueryClient;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function makeQueryClient(): QueryClient {
|
|
38
|
+
return new QueryClient({
|
|
39
|
+
defaultOptions: {
|
|
40
|
+
queries: {
|
|
41
|
+
staleTime: 60_000,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Label } from "@percepta/design";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { compact } from "lodash-es";
|
|
4
|
+
import React, { useId } from "react";
|
|
5
|
+
import { type ControllerFieldState } from "react-hook-form";
|
|
6
|
+
import { cn } from "../../utils/cn";
|
|
7
|
+
|
|
8
|
+
interface FormItemProps extends React.ComponentProps<"div"> {
|
|
9
|
+
label: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
message?: React.ReactNode;
|
|
12
|
+
fieldState: ControllerFieldState;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const FormItem: React.FC<FormItemProps> = ({
|
|
16
|
+
className,
|
|
17
|
+
label,
|
|
18
|
+
description,
|
|
19
|
+
message,
|
|
20
|
+
fieldState: { error },
|
|
21
|
+
children,
|
|
22
|
+
...props
|
|
23
|
+
}) => {
|
|
24
|
+
const labelId = useId();
|
|
25
|
+
const descriptionId = useId();
|
|
26
|
+
const messageId = useId();
|
|
27
|
+
|
|
28
|
+
function maybeRenderMessage() {
|
|
29
|
+
const body = error?.message ?? message;
|
|
30
|
+
if (body == null) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<p
|
|
36
|
+
id={messageId}
|
|
37
|
+
className="text-destructive-foreground text-sm"
|
|
38
|
+
data-slot="form-message"
|
|
39
|
+
>
|
|
40
|
+
{body}
|
|
41
|
+
</p>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
data-slot="form-item"
|
|
48
|
+
className={cn("grid gap-2", className)}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
<Label
|
|
52
|
+
className="data-[error=true]:text-destructive-foreground"
|
|
53
|
+
htmlFor={labelId}
|
|
54
|
+
data-slot="form-label"
|
|
55
|
+
data-error={error != null}
|
|
56
|
+
>
|
|
57
|
+
{label}
|
|
58
|
+
</Label>
|
|
59
|
+
<Slot
|
|
60
|
+
id={labelId}
|
|
61
|
+
data-slot="form-control"
|
|
62
|
+
aria-describedby={compact([
|
|
63
|
+
descriptionId,
|
|
64
|
+
error != null && messageId,
|
|
65
|
+
]).join(" ")}
|
|
66
|
+
aria-invalid={error != null}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
</Slot>
|
|
70
|
+
{description != null && (
|
|
71
|
+
<p
|
|
72
|
+
id={descriptionId}
|
|
73
|
+
className="text-muted-foreground text-sm"
|
|
74
|
+
data-slot="form-description"
|
|
75
|
+
>
|
|
76
|
+
{description}
|
|
77
|
+
</p>
|
|
78
|
+
)}
|
|
79
|
+
{maybeRenderMessage()}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
export function getClientEnvConfig() {
|
|
4
|
+
return {
|
|
5
|
+
FARO_COLLECTOR_URL: process.env.NEXT_PUBLIC_FARO_COLLECTOR_URL,
|
|
6
|
+
FARO_APP_NAME: process.env.NEXT_PUBLIC_FARO_APP_NAME ?? "__APP_NAME__",
|
|
7
|
+
FARO_APP_VERSION: process.env.NEXT_PUBLIC_FARO_APP_VERSION ?? "0.0.0",
|
|
8
|
+
FARO_APP_ENVIRONMENT:
|
|
9
|
+
process.env.NEXT_PUBLIC_FARO_APP_ENVIRONMENT ?? process.env.NODE_ENV,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createEnvConfig } from "@percepta/utils";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Application-specific environment configuration.
|
|
6
|
+
* Extends the base config from @percepta/utils which includes NODE_ENV and LOG_LEVEL.
|
|
7
|
+
*/
|
|
8
|
+
export const { getEnvConfig, schema: ENV_CONFIG_SCHEMA } = createEnvConfig(
|
|
9
|
+
z.object({
|
|
10
|
+
// Application:
|
|
11
|
+
APP_BASE_URL: z.string().optional(),
|
|
12
|
+
|
|
13
|
+
// Database:
|
|
14
|
+
DATABASE_HOST: z.string().default("localhost"),
|
|
15
|
+
DATABASE_PORT: z.coerce.number().int().default(5434),
|
|
16
|
+
DATABASE_USERNAME: z.string().default("postgres"),
|
|
17
|
+
DATABASE_PASSWORD: z.string().default("postgres"),
|
|
18
|
+
DATABASE_NAME: z.string().default("__DB_NAME__"),
|
|
19
|
+
DATABASE_USE_SSL: z
|
|
20
|
+
.string()
|
|
21
|
+
.transform((value: string): boolean => value === "true")
|
|
22
|
+
.default(false),
|
|
23
|
+
|
|
24
|
+
// AWS:
|
|
25
|
+
AWS_REGION: z.string().default("us-east-1"),
|
|
26
|
+
|
|
27
|
+
// Authentication (Better Auth):
|
|
28
|
+
BETTER_AUTH_SECRET: z.string().optional(),
|
|
29
|
+
BETTER_AUTH_URL: z.string().default("http://localhost:3000"),
|
|
30
|
+
|
|
31
|
+
// Inngest:
|
|
32
|
+
INNGEST_BASE_URL: z.string().optional(),
|
|
33
|
+
INNGEST_APP_URL: z.string().optional(),
|
|
34
|
+
INNGEST_SIGNING_KEY: z.string().optional(),
|
|
35
|
+
INNGEST_EVENT_KEY: z.string().optional(),
|
|
36
|
+
SKIP_INNGEST_SYNC: z
|
|
37
|
+
.string()
|
|
38
|
+
.transform((value: string): boolean => value === "true" || value === "1")
|
|
39
|
+
.default(false),
|
|
40
|
+
|
|
41
|
+
// Langfuse:
|
|
42
|
+
LANGFUSE_BASE_URL: z.string().optional(),
|
|
43
|
+
LANGFUSE_PUBLIC_KEY: z.string().optional(),
|
|
44
|
+
LANGFUSE_SECRET_KEY: z.string().optional(),
|
|
45
|
+
|
|
46
|
+
// Security:
|
|
47
|
+
ENCRYPTION_SECRET_KEY: z.string().optional(),
|
|
48
|
+
TRIGGER_ENDPOINT_API_KEY: z.string().optional(),
|
|
49
|
+
|
|
50
|
+
// LLM/AI providers:
|
|
51
|
+
OPENAI_API_KEY: z.string().optional(),
|
|
52
|
+
|
|
53
|
+
// Readonly database (scripts):
|
|
54
|
+
READONLY_SECRET_NAME: z.string().optional(),
|
|
55
|
+
|
|
56
|
+
// Application specific variables:
|
|
57
|
+
|
|
58
|
+
// APP_SPECIFIC_VARIABLE: z.string().optional(),
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export type EnvConfig = ReturnType<typeof getEnvConfig>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type NodePgDatabase, drizzle } from "drizzle-orm/node-postgres";
|
|
2
|
+
import { Pool } from "pg";
|
|
3
|
+
import { getEnvConfig } from "../config/getEnvConfig";
|
|
4
|
+
import * as schema from "./schema";
|
|
5
|
+
|
|
6
|
+
export const { client, db } = createDb();
|
|
7
|
+
|
|
8
|
+
function createDb(): { client: Pool; db: NodePgDatabase<typeof schema> } {
|
|
9
|
+
const {
|
|
10
|
+
DATABASE_HOST: host,
|
|
11
|
+
DATABASE_PORT: port,
|
|
12
|
+
DATABASE_USERNAME: user,
|
|
13
|
+
DATABASE_PASSWORD: password,
|
|
14
|
+
DATABASE_NAME: database,
|
|
15
|
+
DATABASE_USE_SSL: useSSL,
|
|
16
|
+
} = getEnvConfig();
|
|
17
|
+
|
|
18
|
+
const _client = new Pool({
|
|
19
|
+
host,
|
|
20
|
+
port,
|
|
21
|
+
user,
|
|
22
|
+
password,
|
|
23
|
+
database,
|
|
24
|
+
ssl: useSSL,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return { client: _client, db: drizzle(_client, { schema }) };
|
|
28
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
CREATE TABLE "account" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"user_id" uuid NOT NULL,
|
|
4
|
+
"account_id" text NOT NULL,
|
|
5
|
+
"provider_id" text NOT NULL,
|
|
6
|
+
"access_token" text,
|
|
7
|
+
"refresh_token" text,
|
|
8
|
+
"expires_at" integer,
|
|
9
|
+
"access_token_expires_at" timestamp,
|
|
10
|
+
"refresh_token_expires_at" timestamp,
|
|
11
|
+
"scope" text,
|
|
12
|
+
"id_token" text,
|
|
13
|
+
"password" text,
|
|
14
|
+
"created_at" timestamp NOT NULL,
|
|
15
|
+
"updated_at" timestamp NOT NULL
|
|
16
|
+
);
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
CREATE TABLE "session" (
|
|
19
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
20
|
+
"user_id" uuid NOT NULL,
|
|
21
|
+
"token" text NOT NULL,
|
|
22
|
+
"expires_at" timestamp NOT NULL,
|
|
23
|
+
"ip_address" text,
|
|
24
|
+
"user_agent" text,
|
|
25
|
+
"impersonated_by" text,
|
|
26
|
+
"created_at" timestamp NOT NULL,
|
|
27
|
+
"updated_at" timestamp NOT NULL,
|
|
28
|
+
CONSTRAINT "session_token_unique" UNIQUE("token")
|
|
29
|
+
);
|
|
30
|
+
--> statement-breakpoint
|
|
31
|
+
CREATE TABLE "users" (
|
|
32
|
+
"id" uuid PRIMARY KEY NOT NULL,
|
|
33
|
+
"name" text NOT NULL,
|
|
34
|
+
"email" text NOT NULL,
|
|
35
|
+
"email_verified" boolean DEFAULT false NOT NULL,
|
|
36
|
+
"image" text,
|
|
37
|
+
"role" text DEFAULT 'user' NOT NULL,
|
|
38
|
+
"banned" boolean DEFAULT false,
|
|
39
|
+
"ban_reason" text,
|
|
40
|
+
"ban_expires" timestamp,
|
|
41
|
+
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
42
|
+
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
43
|
+
CONSTRAINT "users_email_unique" UNIQUE("email")
|
|
44
|
+
);
|
|
45
|
+
--> statement-breakpoint
|
|
46
|
+
CREATE TABLE "verification" (
|
|
47
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
48
|
+
"identifier" text NOT NULL,
|
|
49
|
+
"value" text NOT NULL,
|
|
50
|
+
"expires_at" timestamp NOT NULL,
|
|
51
|
+
"created_at" timestamp,
|
|
52
|
+
"updated_at" timestamp
|
|
53
|
+
);
|
|
54
|
+
--> statement-breakpoint
|
|
55
|
+
ALTER TABLE "account" ADD CONSTRAINT "account_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
56
|
+
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
57
|
+
CREATE UNIQUE INDEX "lower_email_index" ON "users" USING btree (lower("email"));
|