feat: use prisma and postgresql
This commit is contained in:
parent
c0eace8efe
commit
0f2abe9e44
36
.env.example
36
.env.example
|
|
@ -13,4 +13,38 @@ NEXT_PUBLIC_CSB_SCAN="https://scan.crossbell.io"
|
|||
NEXT_PUBLIC_IPFS_GATEWAY="https://ipfs.4everland.xyz/ipfs/"
|
||||
NEXT_PUBLIC_MIRA_LINK="https://mira.crossbell.io"
|
||||
|
||||
REDIS_URL=
|
||||
# NFT
|
||||
|
||||
MORALIS_WEB3_API_KEY=
|
||||
ALCHEMY_ETHEREUM_API_KEY=
|
||||
ALCHEMY_POLYGON_API_KEY=
|
||||
NFTSCAN_API_KEY=
|
||||
OPENSEA_API_KEY=
|
||||
POAP_API_KEY=
|
||||
|
||||
# OPENAI
|
||||
|
||||
OPENAI_API_KEY=
|
||||
|
||||
# POSTGRES
|
||||
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=password
|
||||
POSTGRES_DB=indexer
|
||||
|
||||
# Nest run locally
|
||||
|
||||
DB_HOST=localhost
|
||||
|
||||
# DB_HOST=postgres
|
||||
|
||||
DB_PORT=5432
|
||||
DB_SCHEMA=public
|
||||
|
||||
# Prisma database connection
|
||||
|
||||
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOST}:${DB_PORT}/${POSTGRES_DB}?schema=${DB_SCHEMA}&sslmode=prefer&connection_limit=400&pool_timeout=30
|
||||
|
||||
# Redis database connection
|
||||
|
||||
REDIS_URL=redis://localhost:6379
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
version: "3.7"
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:latest
|
||||
container_name: postgres
|
||||
restart: always
|
||||
ports:
|
||||
- 5432:5432
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- postgres:/var/lib/postgresql/data
|
||||
redis:
|
||||
image: redis/redis-stack:latest
|
||||
container_name: redis-stack
|
||||
restart: always
|
||||
ports:
|
||||
- 6379:6379
|
||||
- 8001:8001
|
||||
volumes:
|
||||
- redis:/var/lib/redis/data
|
||||
|
||||
volumes:
|
||||
postgres:
|
||||
name: xlog-db
|
||||
redis:
|
||||
name: xlog-redis
|
||||
|
|
@ -11,7 +11,10 @@
|
|||
"test-e2e": "playwright test",
|
||||
"start": "node server.js",
|
||||
"uno-generate": "unocss \"src/**/*.{ts,tsx}\" -o src/generated/uno.css",
|
||||
"prepare": "husky install"
|
||||
"prepare": "husky install",
|
||||
"prisma:generate": "prisma generate",
|
||||
"prisma:studio": "prisma studio",
|
||||
"docker:db": "docker-compose -f docker-compose.db.yml up -d"
|
||||
},
|
||||
"lint-staged": {
|
||||
"**/*": "prettier --write --ignore-unknown"
|
||||
|
|
@ -36,6 +39,7 @@
|
|||
"@iconify-json/mingcute": "^1.1.5",
|
||||
"@mantine/core": "^6.0.4",
|
||||
"@monaco-editor/react": "4.4.6",
|
||||
"@prisma/client": "^4.12.0",
|
||||
"@tanstack/react-query": "4.28.0",
|
||||
"@tanstack/react-query-devtools": "4.28.0",
|
||||
"@tanstack/react-query-persist-client": "4.28.0",
|
||||
|
|
@ -142,6 +146,7 @@
|
|||
"next-pwa": "^5.6.0",
|
||||
"postcss-import": "15.1.0",
|
||||
"prettier": "2.8.6",
|
||||
"prisma": "^4.12.0",
|
||||
"tailwindcss": "3.2.7",
|
||||
"typescript": "5.0.2",
|
||||
"unocss": "0.50.6",
|
||||
|
|
|
|||
5017
pnpm-lock.yaml
5017
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,19 @@
|
|||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Metadata {
|
||||
uri String
|
||||
aiSummary String?
|
||||
aiScore Int?
|
||||
@@id([uri])
|
||||
@@index([uri])
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import { PrismaClient } from "@prisma/client"
|
||||
|
||||
let prisma: PrismaClient
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
prisma = new PrismaClient()
|
||||
} else {
|
||||
if (!global.prisma) {
|
||||
global.prisma = new PrismaClient()
|
||||
}
|
||||
prisma = global.prisma
|
||||
}
|
||||
|
||||
export default prisma
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import { PrismaClient } from "@prisma/client"
|
||||
|
||||
export {}
|
||||
|
||||
declare global {
|
||||
|
|
@ -7,4 +9,6 @@ declare global {
|
|||
thisArg?: any,
|
||||
): number
|
||||
}
|
||||
|
||||
var prisma: PrismaClient | undefined
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue