Skip to content

Commit 90df0e5

Browse files
chore: support db
1 parent 29babe5 commit 90df0e5

13 files changed

+464
-37
lines changed

.env

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Environment variables declared in this file are automatically made available to Prisma.
2+
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
3+
4+
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
5+
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
6+
7+
DATABASE_URL="file:./db/sqlite3.db"

app/auto-imports.d.ts

+290
Large diffs are not rendered by default.

app/lib/db.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { PrismaClient } from '@prisma/client'
2+
3+
export const prisma = new PrismaClient()

app/routes/home.tsx

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1+
import { prisma } from '@/lib/db'
2+
13
import { Welcome } from '../welcome/welcome'
24
import type { Route } from './+types/home'
35

46
export function meta(_: Route.MetaArgs) {
57
return [
6-
{ title: 'New React Router App' },
7-
{ name: 'description', content: 'Welcome to React Router!' },
8+
{ title: 'fisand-remix' },
9+
{ name: 'description', content: 'Welcome to fisand remix!' },
810
]
911
}
1012

11-
export default function Home() {
12-
return <Welcome />
13+
export async function loader() {
14+
const users = await prisma.user.findMany()
15+
return { users }
16+
}
17+
18+
export default function Home({
19+
loaderData,
20+
}: Route.ComponentProps) {
21+
const author = loaderData.users?.[0]
22+
return <Welcome author={author} />
1323
}

app/welcome/welcome.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import type { User } from '@prisma/client'
2+
13
import { HeroGeometric } from '@/components/layout/HeroSection'
24

3-
export function Welcome() {
5+
export function Welcome({ author }: { author: User }) {
46
return (
57
<HeroGeometric
6-
badge="Fisand template"
8+
badge={`Fisand template created by ${author.name}`}
79
title1="Simple design"
810
title2="Built for efficiency"
911
/>

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
"build": "react-router build",
77
"dev": "react-router dev",
88
"lint": "eslint . --fix",
9+
"prisma:generate": "prisma generate",
910
"start": "react-router-serve ./build/server/index.js",
1011
"typecheck": "react-router typegen && tsc"
1112
},
1213
"dependencies": {
1314
"@hookform/resolvers": "^4.1.2",
15+
"@prisma/client": "6.4.1",
1416
"@radix-ui/react-accordion": "^1.2.3",
1517
"@radix-ui/react-alert-dialog": "^1.1.6",
1618
"@radix-ui/react-aspect-ratio": "^1.1.2",
@@ -52,6 +54,7 @@
5254
"isbot": "^5.1.17",
5355
"lucide-react": "^0.477.0",
5456
"next-themes": "^0.4.4",
57+
"prisma": "^6.4.1",
5558
"react": "^19.0.0",
5659
"react-day-picker": "8.10.1",
5760
"react-dom": "^19.0.0",

pnpm-lock.yaml

+92
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prisma/db/sqlite3.db

28 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- CreateTable
2+
CREATE TABLE "User" (
3+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
4+
"email" TEXT NOT NULL,
5+
"name" TEXT
6+
);
7+
8+
-- CreateTable
9+
CREATE TABLE "Post" (
10+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
11+
"title" TEXT NOT NULL,
12+
"content" TEXT,
13+
"published" BOOLEAN NOT NULL DEFAULT false,
14+
"authorId" INTEGER NOT NULL,
15+
CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
16+
);
17+
18+
-- CreateIndex
19+
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

prisma/migrations/migration_lock.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Please do not edit this file manually
2+
# It should be added in your version-control system (e.g., Git)
3+
provider = "sqlite"

prisma/schema.prisma

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This is your Prisma schema file,
2+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
3+
4+
generator client {
5+
provider = "prisma-client-js"
6+
}
7+
8+
datasource db {
9+
provider = "sqlite"
10+
url = env("DATABASE_URL")
11+
}
12+
13+
model User {
14+
id Int @id @default(autoincrement())
15+
email String @unique
16+
name String?
17+
posts Post[]
18+
}
19+
20+
model Post {
21+
id Int @id @default(autoincrement())
22+
title String
23+
content String?
24+
published Boolean @default(false)
25+
author User @relation(fields: [authorId], references: [id])
26+
authorId Int
27+
}

src/auto-imports.d.ts

-29
This file was deleted.

vite.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export default defineConfig({
1818
compiler: 'jsx',
1919
jsx: 'react',
2020
customCollections: {
21-
'fisand-icons': FileSystemIconLoader(`${resolve(import.meta.dirname, 'src/assets/icons')}/`, svg =>
21+
'fisand-icons': FileSystemIconLoader(`${resolve(import.meta.dirname, 'app/assets/icons')}/`, svg =>
2222
svg.replace(/^<svg /, '<svg fill="currentColor" ')),
2323
},
2424
}),
2525
AutoImport({
2626
imports: ['react'],
27-
dts: './auto-imports.d.ts',
27+
dts: './app/auto-imports.d.ts',
2828
resolvers: [
2929
IconsResolver({
3030
componentPrefix: 'Icon',

0 commit comments

Comments
 (0)