Skip to content

Commit 72c63e8

Browse files
authored
Merge pull request #228 from Markkos89/feat/rainbow-siwe
Feat: RainbowKit connect wallet button and more
2 parents bda9604 + 85933b2 commit 72c63e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1101
-468
lines changed

.env.example

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Prisma
1313
# https://www.prisma.io/docs/reference/database-reference/connection-urls#env
14-
DATABASE_URL="file:./db.sqlite" # unnused now for postgres
14+
# DATABASE_URL="file:./db.sqlite" # unnused now for postgres
1515

1616
# Next Auth
1717
# You can generate a new secret on the command line with:
@@ -20,10 +20,16 @@ DATABASE_URL="file:./db.sqlite" # unnused now for postgres
2020
# NEXTAUTH_SECRET=""
2121
NEXTAUTH_URL="http://localhost:3000"
2222

23+
POSTGRES_HOST=127.0.0.1
24+
POSTGRES_PORT=6500
25+
POSTGRES_USER=admin
26+
POSTGRES_PASSWORD=password123
27+
POSTGRES_DATABASE=nextauth_prisma
28+
29+
DATABASE_URL=postgresql://admin:password123@localhost:6500/nextauth_prisma?schema=public
30+
2331
POSTGRES_URL=
24-
POSTGRES_PRISMA_URL=
25-
POSTGRES_URL_NON_POOLING=
26-
POSTGRES_USER=
27-
POSTGRES_HOST=
28-
POSTGRES_PASSWORD=
29-
POSTGRES_DATABASE=
32+
POSTGRES_PRISMA_URL=postgresql://admin:password123@localhost:6500/nextauth_prisma?schema=public
33+
POSTGRES_URL_NON_POOLING=postgresql://admin:password123@localhost:6500/nextauth_prisma?schema=public
34+
35+
NEXT_PUBLIC_WALLET_CONNECT_ID=

.eslintrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ const config = {
2929
},
3030
],
3131
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
32+
"@typescript-eslint/no-unsafe-assignment": "off", // or "off" if you want to disable it
33+
"@typescript-eslint/no-unsafe-call": "off", // or "off" if you want to disable it
34+
"@typescript-eslint/no-unsafe-return": "off",
35+
"@typescript-eslint/no-unsafe-member-access": "off",
3236
},
3337
};
3438

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ run through the live site and make sure the code is performing as expected.
8181

8282
**Prerequisites:**
8383

84-
node --version 16.x
84+
node --version 18.x
8585

8686
Refer to the `node` and `npm` installation with `nvm` guide in Lesson 2. A link
8787
to the guide can be found

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "3"
2+
services:
3+
postgres:
4+
image: postgres:latest
5+
container_name: postgres
6+
ports:
7+
- "6500:5432"
8+
volumes:
9+
- progresDB:/var/lib/postgresql/data
10+
env_file:
11+
- ./.env
12+
volumes:
13+
progresDB:
File renamed without changes.

next.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ const config = {
4242
},
4343
// Append the default value with md extensions
4444
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
45+
webpack: (config) => {
46+
config.resolve.fallback = { fs: false, net: false, tls: false };
47+
return config;
48+
},
4549
};
4650

4751
export default withMDX(config);

package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
"dev": "next dev",
88
"postinstall": "prisma generate",
99
"lint": "next lint",
10-
"start": "next start"
10+
"start": "next start",
11+
"prisma:seed": "npx prisma db seed"
12+
},
13+
"prisma": {
14+
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
1115
},
1216
"dependencies": {
1317
"@chakra-ui/icons": "^2.0.19",
@@ -16,13 +20,17 @@
1620
"@emotion/styled": "^11.11.0",
1721
"@fontsource/inter": "^5.0.3",
1822
"@next-auth/prisma-adapter": "^1.0.7",
19-
"@prisma/client": "^5.0.0",
23+
"@prisma/client": "^5.1.1",
24+
"@rainbow-me/rainbowkit": "^1.0.8",
25+
"@rainbow-me/rainbowkit-siwe-next-auth": "^0.3.0",
2026
"@tanstack/react-query": "^4.29.19",
27+
"@tanstack/react-query-devtools": "^4.32.5",
2128
"@trpc/client": "^10.33.0",
2229
"@trpc/next": "^10.33.0",
2330
"@trpc/react-query": "^10.33.0",
2431
"@trpc/server": "^10.33.0",
2532
"@vercel/postgres": "^0.4.0",
33+
"bcryptjs": "^2.4.3",
2634
"ethers": "^6",
2735
"framer-motion": "^10.12.17",
2836
"next": "^13.4.7",
@@ -42,6 +50,7 @@
4250
"@mdx-js/loader": "^2.3.0",
4351
"@mdx-js/react": "^2.3.0",
4452
"@next/mdx": "^13.4.8",
53+
"@types/bcryptjs": "^2.4.2",
4554
"@types/eslint": "^8.40.2",
4655
"@types/mdx": "^2.0.5",
4756
"@types/node": "^20.3.2",
@@ -59,11 +68,12 @@
5968
"lint-staged": "^13.2.3",
6069
"postcss": "^8.4.24",
6170
"prettier": "^2.8.8",
62-
"prettier-plugin-tailwindcss": "^0.3.0",
63-
"prisma": "^5.0.0",
71+
"prettier-plugin-tailwindcss": "0.2.1",
72+
"prisma": "^5.1.1",
6473
"react-syntax-highlighter": "^15.5.0",
6574
"remark-frontmatter": "^4.0.1",
6675
"tailwindcss": "^3.3.2",
76+
"ts-node": "^10.9.1",
6777
"typescript": "^5.1.6"
6878
},
6979
"ct3aMetadata": {

prisma/migrations/0_init/migration.sql

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
-- CreateTable
2-
CREATE TABLE "Todo" (
3-
"id" TEXT NOT NULL,
4-
"task" TEXT NOT NULL,
5-
"userId" TEXT NOT NULL,
6-
"completed" BOOLEAN NOT NULL DEFAULT false,
7-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
8-
"updatedAt" TIMESTAMP(3) NOT NULL,
9-
10-
CONSTRAINT "Todo_pkey" PRIMARY KEY ("id")
11-
);
12-
131
-- CreateTable
142
CREATE TABLE "Account" (
153
"id" TEXT NOT NULL,
@@ -31,6 +19,7 @@ CREATE TABLE "Account" (
3119
-- CreateTable
3220
CREATE TABLE "User" (
3321
"id" TEXT NOT NULL,
22+
"password" TEXT,
3423
"name" TEXT,
3524
"address" TEXT,
3625
"email" TEXT,
@@ -41,6 +30,26 @@ CREATE TABLE "User" (
4130
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
4231
);
4332

33+
-- CreateTable
34+
CREATE TABLE "CompletedQuizzes" (
35+
"id" TEXT NOT NULL,
36+
"lesson" TEXT NOT NULL,
37+
"userId" TEXT NOT NULL,
38+
"completed" BOOLEAN NOT NULL DEFAULT false,
39+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
40+
"updatedAt" TIMESTAMP(3) NOT NULL,
41+
42+
CONSTRAINT "CompletedQuizzes_pkey" PRIMARY KEY ("id")
43+
);
44+
45+
-- CreateTable
46+
CREATE TABLE "Lessons" (
47+
"id" TEXT NOT NULL,
48+
"quizFileName" TEXT NOT NULL,
49+
50+
CONSTRAINT "Lessons_pkey" PRIMARY KEY ("id")
51+
);
52+
4453
-- CreateIndex
4554
CREATE UNIQUE INDEX "Account_provider_providerAccountId_key" ON "Account"("provider", "providerAccountId");
4655

@@ -50,9 +59,12 @@ CREATE UNIQUE INDEX "User_address_key" ON "User"("address");
5059
-- CreateIndex
5160
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
5261

53-
-- AddForeignKey
54-
ALTER TABLE "Todo" ADD CONSTRAINT "Todo_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
62+
-- CreateIndex
63+
CREATE UNIQUE INDEX "Lessons_quizFileName_key" ON "Lessons"("quizFileName");
5564

5665
-- AddForeignKey
5766
ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
5867

68+
-- AddForeignKey
69+
ALTER TABLE "CompletedQuizzes" ADD CONSTRAINT "CompletedQuizzes_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
70+

prisma/schema.prisma

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ datasource db {
99
shadowDatabaseUrl = env("POSTGRES_URL_NON_POOLING")
1010
}
1111

12-
model Todo {
13-
id String @id @default(cuid())
14-
task String
15-
userId String
16-
completed Boolean @default(false)
17-
createdAt DateTime @default(now())
18-
updatedAt DateTime @updatedAt
19-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
20-
}
21-
2212
model Account {
2313
id String @id @default(cuid())
2414
userId String
@@ -46,7 +36,6 @@ model User {
4636
image String?
4737
createdAt DateTime @default(now())
4838
accounts Account[]
49-
Todo Todo[]
5039
CompletedQuizzes CompletedQuizzes[]
5140
}
5241

@@ -59,3 +48,9 @@ model CompletedQuizzes {
5948
updatedAt DateTime @updatedAt
6049
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
6150
}
51+
52+
model Lessons {
53+
id String @id @default(cuid())
54+
lessonNumber Int @unique @default(autoincrement())
55+
quizFileName String
56+
}

prisma/seed.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { PrismaClient } from "@prisma/client";
2+
// import { hash } from "bcryptjs";
3+
4+
const prisma = new PrismaClient();
5+
6+
async function main() {
7+
// const password = await hash("password123", 12);
8+
// const user = await prisma.user.upsert({
9+
// where: { email: "admin@admin.com" },
10+
// update: {},
11+
// create: {
12+
// email: "[email protected]",
13+
// name: "Admin",
14+
// password,
15+
// },
16+
// });
17+
// console.log({ user });
18+
19+
const lesson1 = await prisma.lessons.create({
20+
data: {
21+
quizFileName: "quiz-lesson-1.json",
22+
},
23+
});
24+
console.log({ lesson1 });
25+
}
26+
27+
main()
28+
.then(() => prisma.$disconnect())
29+
.catch(async (e) => {
30+
console.error(e);
31+
await prisma.$disconnect();
32+
process.exit(1);
33+
});

0 commit comments

Comments
 (0)