chore: update dependencies

This commit is contained in:
DIYgod
2022-09-22 22:16:43 +01:00
parent 5697ae8159
commit 66c0314a55
27 changed files with 2190 additions and 2280 deletions
+1 -2
View File
@@ -1,8 +1,7 @@
##### BASE
FROM node:16-bullseye-slim as base
# install open ssl for prisma
RUN apt-get update && apt-get install -y openssl
RUN apt-get update
RUN npm i -g pnpm
+66 -71
View File
@@ -5,13 +5,11 @@
"license": "AGPL-3.0",
"sideEffects": false,
"scripts": {
"build": "pnpm db-generate && next build",
"build": "next build",
"dev": "next",
"test-unit": "vitest run",
"test-e2e": "playwright test",
"db-generate": "prisma generate",
"start": "node server.js",
"db-seed": "node -r esbuild-register prisma/seed.ts",
"uno-generate": "unocss \"src/**/*.{ts,tsx}\" -o src/generated/uno.css",
"prepare": "husky install"
},
@@ -19,63 +17,61 @@
"**/*": "prettier --write --ignore-unknown"
},
"dependencies": {
"@codemirror/commands": "^0.20.0",
"@codemirror/lang-markdown": "^0.20.0",
"@codemirror/language": "^0.20.0",
"@codemirror/state": "^0.20.0",
"@codemirror/view": "^0.20.3",
"@crossbell/ipfs-gateway": "0.0.10",
"@crossbell/ipfs-react": "0.0.10",
"@emoji-mart/data": "^1.0.3",
"@emoji-mart/react": "^1.0.0",
"@floating-ui/react-dom-interactions": "^0.6.3",
"@headlessui/react": "^1.6.0",
"@heroicons/react": "^1.0.6",
"@iconify-json/tabler": "^1.1.31",
"@codemirror/commands": "^6.1.0",
"@codemirror/lang-markdown": "^6.0.1",
"@codemirror/language": "^6.2.1",
"@codemirror/state": "^6.1.2",
"@codemirror/view": "^6.2.4",
"@crossbell/ipfs-gateway": "0.0.14",
"@crossbell/ipfs-react": "0.0.14",
"@emoji-mart/data": "^1.0.6",
"@emoji-mart/react": "^1.0.1",
"@floating-ui/react-dom-interactions": "^0.10.1",
"@headlessui/react": "^1.7.2",
"@heroicons/react": "^2.0.11",
"@iconify-json/tabler": "^1.1.35",
"@monaco-editor/react": "^4.4.5",
"@prisma/client": "^3.14.0",
"@proselog/jwt": "^0.1.1",
"@rainbow-me/rainbowkit": "^0.4.5",
"@tanstack/react-query": "^4.0.10",
"@tanstack/react-query-devtools": "^4.0.10",
"@tanstack/react-query-persist-client": "^4.0.10",
"@trpc/client": "^9.23.2",
"@trpc/next": "^9.23.2",
"@trpc/react": "^9.23.2",
"@trpc/server": "^9.23.2",
"@rainbow-me/rainbowkit": "^0.6.1",
"@tanstack/react-query": "^4.3.9",
"@tanstack/react-query-devtools": "^4.3.9",
"@tanstack/react-query-persist-client": "^4.3.9",
"@trpc/client": "^9.27.2",
"@trpc/next": "^9.27.2",
"@trpc/react": "^9.27.2",
"@trpc/server": "^9.27.2",
"@web-std/form-data": "^3.0.2",
"async-busboy": "^1.1.0",
"axios": "^0.27.2",
"busboy": "^1.6.0",
"clsx": "^1.1.1",
"clsx": "^1.2.1",
"cookie": "^0.5.0",
"crossbell.js": "^0.10.28",
"dayjs": "^1.11.1",
"dotenv": "^16.0.0",
"emoji-mart": "^5.2.0",
"ethers": "^5.6.9",
"crossbell.js": "^0.10.30",
"dayjs": "^1.11.5",
"dotenv": "^16.0.2",
"emoji-mart": "^5.2.2",
"ethers": "^5.7.1",
"fast-deep-equal": "^3.1.3",
"form-data": "^4.0.0",
"idb-keyval": "^6.2.0",
"ioredis": "^5.2.2",
"ioredis": "^5.2.3",
"js-yaml": "^4.1.0",
"mailgun.js": "^5.2.2",
"mdast-util-to-string": "^3.1.0",
"nanoid": "^3.3.3",
"next": "^12.1.6",
"nanoid": "^4.0.0",
"next": "^12.3.1",
"pica": "^9.0.1",
"posthtml": "^0.16.6",
"prismjs": "^1.28.0",
"prismjs": "^1.29.0",
"react": "^18.1.0",
"react-avatar-editor": "^12.0.0",
"react-avatar-editor": "^13.0.0",
"react-dom": "^18.1.0",
"react-hook-form": "^7.31.1",
"react-hot-toast": "^2.2.0",
"react-hook-form": "^7.36.0",
"react-hot-toast": "^2.4.0",
"react-infinite-scroller": "^1.2.6",
"react-scroll": "^1.8.7",
"react-sortablejs": "^6.1.1",
"refractor": "^4.7.0",
"rehype-prism-plus": "^1.4.0",
"refractor": "^4.8.0",
"rehype-prism-plus": "^1.5.0",
"rehype-raw": "^6.1.1",
"rehype-sanitize": "^5.0.1",
"rehype-stringify": "^9.0.3",
@@ -89,55 +85,54 @@
"unidata.js": "^0.7.2",
"unified": "^10.1.2",
"unist-builder": "^3.0.0",
"unist-util-visit": "^4.1.0",
"unist-util-visit": "^4.1.1",
"use-onclickoutside": "^0.4.0",
"uuid": "^8.3.2",
"wagmi": "^0.6.1",
"web3.storage": "^4.3.0",
"zod": "^3.15.1",
"zustand": "4.0.0-rc.1"
"uuid": "^9.0.0",
"wagmi": "^0.6.7",
"web3.storage": "^4.4.0",
"zod": "^3.19.1",
"zustand": "4.1.1"
},
"devDependencies": {
"@crossbell/ipfs-gateway-next": "0.0.10",
"@iconify-json/bi": "^1.1.3",
"@iconify-json/bxs": "^1.1.2",
"@iconify-json/carbon": "^1.1.5",
"@iconify-json/fluent": "^1.1.8",
"@iconify-json/mdi": "^1.1.19",
"@playwright/test": "^1.22.1",
"@crossbell/ipfs-gateway-next": "0.0.14",
"@iconify-json/bi": "^1.1.8",
"@iconify-json/bxs": "^1.1.4",
"@iconify-json/carbon": "^1.1.8",
"@iconify-json/fluent": "^1.1.16",
"@iconify-json/mdi": "^1.1.33",
"@playwright/test": "^1.26.0",
"@types/async-busboy": "^1.1.1",
"@types/busboy": "^1.5.0",
"@types/cookie": "^0.5.1",
"@types/js-yaml": "^4.0.5",
"@types/mjml": "^4.7.0",
"@types/node": "^17.0.31",
"@types/node": "^18.7.18",
"@types/pica": "^9.0.0",
"@types/prismjs": "^1.26.0",
"@types/react": "^18.0.9",
"@types/react-avatar-editor": "^12.0.0",
"@types/react-dom": "^18.0.3",
"@types/react": "^18.0.21",
"@types/react-avatar-editor": "^13.0.0",
"@types/react-dom": "^18.0.6",
"@types/react-infinite-scroller": "^1.2.3",
"@types/react-scroll": "^1.8.4",
"@types/sortablejs": "^1.13.0",
"@types/sortablejs": "^1.15.0",
"@types/ua-parser-js": "^0.7.36",
"@types/uuid": "^8.3.4",
"@unocss/cli": "^0.34.1",
"@unocss/preset-icons": "^0.34.1",
"autoprefixer": "^10.4.7",
"@unocss/cli": "^0.45.22",
"@unocss/preset-icons": "^0.45.22",
"autoprefixer": "^10.4.12",
"cross-spawn": "^7.0.3",
"esbuild": "^0.14.39",
"esbuild": "^0.15.9",
"esbuild-register": "^3.3.2",
"eslint": "^8.15.0",
"eslint-config-next": "^12.1.6",
"eslint": "^8.23.1",
"eslint-config-next": "^12.3.1",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"postcss-import": "^14.1.0",
"postcss-import": "^15.0.0",
"prettier": "^2.7.1",
"prisma": "^3.14.0",
"tailwindcss": "^3.0.24",
"typescript": "^4.5.5",
"unocss": "^0.34.1",
"vitest": "^0.12.9"
"tailwindcss": "^3.1.8",
"typescript": "^4.8.3",
"unocss": "^0.45.22",
"vitest": "^0.23.4"
},
"engines": {
"node": ">=14"
+2076 -1638
View File
File diff suppressed because it is too large Load Diff
@@ -1,143 +0,0 @@
-- CreateEnum
CREATE TYPE "MembershipRole" AS ENUM ('OWNER', 'ADMIN', 'SUBSCRIBER');
-- CreateEnum
CREATE TYPE "PageType" AS ENUM ('POST', 'PAGE');
-- CreateTable
CREATE TABLE "users" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"username" TEXT NOT NULL,
"email" TEXT NOT NULL,
"emailVerified" TIMESTAMP(3),
"avatar" TEXT,
"bio" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "login_tokens" (
"id" TEXT NOT NULL,
"email" TEXT NOT NULL,
"expiresAt" TIMESTAMP(3) NOT NULL,
"subscribeForm" JSONB,
CONSTRAINT "login_tokens_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "access_tokens" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"name" TEXT NOT NULL,
"token" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"publicId" TEXT,
"publicIdExpiresAt" TIMESTAMP(3),
CONSTRAINT "access_tokens_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "memberships" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" TEXT NOT NULL,
"siteId" TEXT NOT NULL,
"role" "MembershipRole" NOT NULL,
"acceptedAt" TIMESTAMP(3),
"lastSwitchedTo" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"config" JSONB NOT NULL DEFAULT '{}',
CONSTRAINT "memberships_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "sites" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"name" TEXT NOT NULL,
"icon" TEXT,
"subdomain" TEXT NOT NULL,
"description" TEXT,
"twitter" TEXT,
"navigation" JSONB,
"deletedAt" TIMESTAMP(3),
CONSTRAINT "sites_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "pages" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"contentUpdatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"publishedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"published" BOOLEAN NOT NULL DEFAULT false,
"type" "PageType" NOT NULL DEFAULT E'POST',
"title" TEXT NOT NULL,
"content" TEXT NOT NULL,
"excerpt" TEXT,
"format" TEXT NOT NULL DEFAULT E'markdown',
"slug" TEXT NOT NULL,
"siteId" TEXT NOT NULL,
"deletedAt" TIMESTAMP(3),
"subscribersNotifiedAt" TIMESTAMP(3),
CONSTRAINT "pages_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "_PageToUser" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "users_username_key" ON "users"("username");
-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
-- CreateIndex
CREATE UNIQUE INDEX "access_tokens_token_key" ON "access_tokens"("token");
-- CreateIndex
CREATE UNIQUE INDEX "access_tokens_publicId_key" ON "access_tokens"("publicId");
-- CreateIndex
CREATE UNIQUE INDEX "sites_subdomain_key" ON "sites"("subdomain");
-- CreateIndex
CREATE UNIQUE INDEX "pages_siteId_slug_key" ON "pages"("siteId", "slug");
-- CreateIndex
CREATE UNIQUE INDEX "_PageToUser_AB_unique" ON "_PageToUser"("A", "B");
-- CreateIndex
CREATE INDEX "_PageToUser_B_index" ON "_PageToUser"("B");
-- AddForeignKey
ALTER TABLE "access_tokens" ADD CONSTRAINT "access_tokens_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "memberships" ADD CONSTRAINT "memberships_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "memberships" ADD CONSTRAINT "memberships_siteId_fkey" FOREIGN KEY ("siteId") REFERENCES "sites"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pages" ADD CONSTRAINT "pages_siteId_fkey" FOREIGN KEY ("siteId") REFERENCES "sites"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_PageToUser" ADD CONSTRAINT "_PageToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "pages"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_PageToUser" ADD CONSTRAINT "_PageToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -1,11 +0,0 @@
/*
Warnings:
- A unique constraint covering the columns `[analyticsId]` on the table `sites` will be added. If there are existing duplicate values, this will fail.
*/
-- AlterTable
ALTER TABLE "sites" ADD COLUMN "analyticsId" TEXT;
-- CreateIndex
CREATE UNIQUE INDEX "sites_analyticsId_key" ON "sites"("analyticsId");
@@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "pages" ADD COLUMN "rendered" JSONB;
@@ -1,13 +0,0 @@
/*
Warnings:
- You are about to drop the column `subscribersNotifiedAt` on the `pages` table. All the data in the column will be lost.
*/
-- CreateEnum
CREATE TYPE "PageEmailStatus" AS ENUM ('PENDING', 'RUNNING', 'SUCCESS', 'FAILED');
-- AlterTable
ALTER TABLE "pages" DROP COLUMN "subscribersNotifiedAt",
ADD COLUMN "emailStatus" "PageEmailStatus",
ADD COLUMN "emailSubject" TEXT;
-3
View File
@@ -1,3 +0,0 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
-135
View File
@@ -1,135 +0,0 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id String @id @default(uuid())
name String
username String @unique
email String @unique
emailVerified DateTime?
avatar String?
bio String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
memberships Membership[]
accessTokens AccessToken[]
authoredPages Page[]
@@map("users")
}
model LoginToken {
id String @id @default(uuid())
email String
expiresAt DateTime
// When the login token is creating by submitting the `subscribe` form
// We store extra info here, like `{email: true}`
subscribeForm Json?
@@map("login_tokens")
}
model AccessToken {
id String @id @default(uuid())
createdAt DateTime @default(now())
name String
token String @unique
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
// Allow to get the access token via publicId in /api/login-complete
publicId String? @unique
publicIdExpiresAt DateTime?
@@map("access_tokens")
}
enum MembershipRole {
// The creator
OWNER
// The admins
ADMIN
// The subscribers
SUBSCRIBER
}
model Membership {
id String @id @default(uuid())
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
site Site @relation(fields: [siteId], references: [id], onDelete: Cascade)
userId String
siteId String
role MembershipRole
acceptedAt DateTime?
// Last time the user switched to this membership using the site switcher in the dashboard
lastSwitchedTo DateTime @default(now())
config Json @default("{}")
@@map("memberships")
}
model Site {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
icon String?
subdomain String @unique
pages Page[] @relation(name: "SitePages")
description String?
twitter String?
navigation Json?
deletedAt DateTime?
memberships Membership[]
analyticsId String? @unique
@@map("sites")
}
enum PageType {
POST
PAGE
}
enum PageEmailStatus {
PENDING
RUNNING
SUCCESS
FAILED
}
model Page {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
contentUpdatedAt DateTime @default(now())
publishedAt DateTime @default(now())
published Boolean @default(false)
type PageType @default(POST)
title String
content String
excerpt String?
format String @default("markdown")
slug String
site Site @relation(name: "SitePages", fields: [siteId], references: [id], onDelete: Cascade)
siteId String
deletedAt DateTime?
authors User[]
// prerendered markdown to html, including extra data like excerpt
rendered Json?
emailSubject String?
emailStatus PageEmailStatus?
@@unique([siteId, slug])
@@map("pages")
}
-56
View File
@@ -1,56 +0,0 @@
import "dotenv/config"
import p from "@prisma/client"
async function main() {
const prisma = new p.PrismaClient()
const writer = await prisma.user.create({
data: {
email: "writer@test.com",
username: "writer",
name: "Writer",
},
})
const site = await prisma.site.create({
data: {
name: `Writer's blog`,
subdomain: "writer",
memberships: {
create: {
role: "OWNER",
user: {
connect: {
id: writer.id,
},
},
},
},
},
})
const subscriber = await prisma.user.create({
data: {
email: "subscriber@test.com",
username: "subscriber",
name: "Subscriber",
memberships: {
create: {
role: "SUBSCRIBER",
site: {
connect: {
id: site.id,
},
},
},
},
},
})
console.log("success!")
}
main().catch((error) => {
console.error(error)
process.exit(1)
})
+1 -1
View File
@@ -2,7 +2,7 @@ import { CSB_SCAN } from "~/lib/env"
import { UniLink } from "../ui/UniLink"
import { Profile, Note } from "~/lib/types"
import { Disclosure } from "@headlessui/react"
import { ChevronUpIcon } from "@heroicons/react/solid"
import { ChevronUpIcon } from "@heroicons/react/20/solid"
import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
import { toIPFS, toGateway } from "~/lib/ipfs-parser"
import { IPFS_SW_GATEWAY_PREFIX } from "~/lib/ipfs-gateway"
+3 -3
View File
@@ -19,7 +19,7 @@ import data from "@emoji-mart/data"
// @ts-ignore
import Picker from "@emoji-mart/react"
import { Popover } from "@headlessui/react"
import { EmojiHappyIcon } from "@heroicons/react/outline"
import { FaceSmileIcon } from "@heroicons/react/24/outline"
import { CSB_SCAN } from "~/lib/env"
import { getSiteLink } from "~/lib/helpers"
@@ -112,11 +112,11 @@ export const Comment: React.FC<{
/>
</div>
<div className="flex justify-between">
<Popover className="relative">
<Popover className="relative flex justify-center">
{({ open }: { open: boolean }) => (
<>
<Popover.Button className="group inline-flex items-center rounded-md px-2 text-xl">
<EmojiHappyIcon className="w-6 h-6 text-zinc-400 hover:text-zinc-500" />
<FaceSmileIcon className="w-6 h-6 text-zinc-400 hover:text-zinc-500" />
</Popover.Button>
<Popover.Panel className="absolute left-0 mt-3 ">
<Picker
+9 -4
View File
@@ -7,7 +7,10 @@ import type { HeaderLinkType } from "~/components/site/SiteHeader"
import { DashboardIcon } from "../icons/DashboardIcon"
import { UniLink } from "../ui/UniLink"
import { useEffect, useState } from "react"
import { DuplicateIcon, LogoutIcon } from "@heroicons/react/outline"
import {
Square2StackIcon,
ArrowRightOnRectangleIcon,
} from "@heroicons/react/24/outline"
import { BigNumber } from "ethers"
import { SITE_URL } from "~/lib/env"
@@ -28,7 +31,7 @@ export const ConnectButton: React.FC<{
const dropdownLinks: HeaderLinkType[] = [
{
icon: <DuplicateIcon className="w-4 h-4" />,
icon: <Square2StackIcon className="w-4 h-4" />,
label: copyLabel,
onClick() {
navigator.clipboard.writeText(address || "")
@@ -44,7 +47,7 @@ export const ConnectButton: React.FC<{
url: `${SITE_URL}/dashboard`,
},
{
icon: <LogoutIcon className="w-4 h-4" />,
icon: <ArrowRightOnRectangleIcon className="w-4 h-4" />,
label: "Disconnect",
onClick() {
disconnect()
@@ -61,7 +64,9 @@ export const ConnectButton: React.FC<{
useEffect(() => {
if (balance !== undefined) {
if (
balance.value.gt(BigNumber.from("1" + "0".repeat(balance.decimals - 2)))
BigNumber.from(balance.value).gt(
BigNumber.from("1" + "0".repeat(balance.decimals - 2)),
)
) {
setInsufficientBalance(false)
} else {
+2 -2
View File
@@ -16,7 +16,7 @@ import {
useDeletePage,
useCreateOrUpdatePage,
} from "~/queries/page"
import { DotsHorizontalIcon } from "@heroicons/react/solid"
import { EllipsisHorizontalIcon } from "@heroicons/react/20/solid"
import { delStorage, getStorage, setStorage } from "~/lib/storage"
import { useQueryClient } from "@tanstack/react-query"
import { Button } from "../ui/Button"
@@ -376,7 +376,7 @@ export const PagesManager: React.FC<{
e.stopPropagation()
}}
>
<DotsHorizontalIcon className="w-5 h-5" />
<EllipsisHorizontalIcon className="w-5 h-5" />
</button>
</Menu.Button>
<Menu.Items className="text-sm absolute z-20 right-0 bg-white shadow-modal rounded-lg overflow-hidden py-2 w-64">
-1
View File
@@ -16,7 +16,6 @@ import { useState, useEffect } from "react"
import { Button } from "../ui/Button"
import { useRouter } from "next/router"
import { SITE_URL, CSB_SCAN } from "~/lib/env"
import { DuplicateIcon } from "@heroicons/react/solid"
import { Comment } from "~/components/common/Comment"
import { UniLink } from "~/components/ui/UniLink"
import { Modal } from "~/components/ui/Modal"
+2 -2
View File
@@ -20,7 +20,7 @@ import {
import { useConnectModal } from "@rainbow-me/rainbowkit"
import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
import { RSS3Icon } from "~/components/icons/RSS3Icon"
import { DotsHorizontalIcon, RssIcon } from "@heroicons/react/solid"
import { EllipsisHorizontalIcon, RssIcon } from "@heroicons/react/20/solid"
import type { Link } from "unidata.js"
import { getSiteSubscriptions } from "~/models/site.model"
import { CharacterList } from "~/components/common/CharacterList"
@@ -272,7 +272,7 @@ export const SiteHeader: React.FC<{
e.stopPropagation()
}}
>
<DotsHorizontalIcon className="w-5 h-5" />
<EllipsisHorizontalIcon className="w-5 h-5" />
</Button>
<div className="absolute hidden right-0 sm:left-0 pt-2 group-hover:block top-full z-10 text-gray-600 w-60">
<div className="bg-white rounded-lg ring-1 ring-zinc-100 min-w-[140px] shadow-md py-2 text-sm">
-10
View File
@@ -4,7 +4,6 @@ import { SEOHead } from "../common/SEOHead"
import { SiteFooter } from "./SiteFooter"
import { SiteHeader } from "./SiteHeader"
import { useRouter } from "next/router"
import { useStore } from "~/lib/store"
import { BlockchainInfo } from "~/components/common/BlockchainInfo"
import { useGetSiteSubscriptions } from "~/queries/site"
import { useGetSite } from "~/queries/site"
@@ -28,20 +27,11 @@ export const SiteLayout: React.FC<SiteLayoutProps> = ({ children, title }) => {
includeAuthors: true,
})
const setSubscribeModalOpened = useStore(
(store) => store.setSubscribeModalOpened,
)
const site = useGetSite(domainOrSubdomain)
const subscriptions = useGetSiteSubscriptions({
siteId: domainOrSubdomain,
})
useEffect(() => {
if ("subscription" in router.query) {
setSubscribeModalOpened(true)
}
}, [setSubscribeModalOpened, router.query])
return (
<>
<SEOHead
-63
View File
@@ -1,63 +0,0 @@
import { PrismaClient, type Prisma } from "@prisma/client"
import { IS_BROWSER, IS_PROD } from "./constants"
import { singleton } from "./singleton.server"
const logLevel: Prisma.LogLevel[] = IS_PROD
? ["info", "error", "warn"]
: ["info", "warn", "error", "query"]
const createPrisma = (readonly: boolean) => {
if (!IS_PROD && !IS_BROWSER) {
for (const k in require.cache) {
if (k.includes("prisma")) {
delete require.cache[k]
}
}
}
let url = process.env.DATABASE_URL
// DATABASE_URL is not set during production build in docker
// But Prisma is actually used there, so just return a fake one
// It's weird that @__PURE__ doesn't work for Next.js
if (!url) return {} as PrismaClient
if (url && readonly && IS_PROD) {
url = url.replace(":5432", ":5433")
}
console.log("connecting to", url)
const client = new PrismaClient({
log: logLevel,
datasources: url
? {
db: {
url,
},
}
: undefined,
})
client.$use(async (params, next) => {
const now = Date.now()
const result = await next(params)
const end = Date.now()
const duration = Math.floor(end - now)
console.log("query took", duration, "ms")
// See results here
return result
})
return client
}
export const prismaPrimary = /* @__PURE__ */ singleton("prisma-primary", () =>
createPrisma(false),
)
export const prismaRead = /* @__PURE__ */ singleton("prisma-read", () =>
createPrisma(true),
)
export * from "@prisma/client"
+2 -12
View File
@@ -7,17 +7,8 @@ export const getTenant = async (request: Request, search: URLSearchParams) => {
throw new Error("missing OUR_DOMAIN env")
}
if (search.has("tenant")) {
return {
subdomain: search.get("tenant"),
}
}
const OUR_DOMAIN_SUFFIX = `.${OUR_DOMAIN}`
if (host) {
if (host.endsWith(".fly.dev")) {
return
}
if (host && host !== OUR_DOMAIN) {
if (host.endsWith(OUR_DOMAIN_SUFFIX)) {
const subdomain = host.replace(OUR_DOMAIN_SUFFIX, "")
const res = await fetch(
@@ -40,8 +31,7 @@ export const getTenant = async (request: Request, search: URLSearchParams) => {
subdomain: subdomain,
}
}
}
if (host !== OUR_DOMAIN) {
} else {
const res = await fetch(
`https://cloudflare-dns.com/dns-query?name=_xlog-challenge.${host}&type=TXT`,
{
+6 -25
View File
@@ -15,28 +15,15 @@ const ALWAYS_REPLAY_ROUTES = [
export default async function middleware(req: NextRequest) {
const { pathname } = req.nextUrl
if (pathname === "/favicon.ico") {
return new Response(null, { status: 404 })
}
console.log(`${req.method} ${req.nextUrl.pathname}${req.nextUrl.search}`)
if (
IS_PROD &&
!IS_PRIMARY_REGION &&
(!METHODS_TO_NOT_REPLAY.includes(req.method) ||
ALWAYS_REPLAY_ROUTES.includes(pathname))
pathname.startsWith("/api/") ||
pathname.startsWith("/dashboard") ||
pathname.startsWith("/_next") ||
pathname === "/ipfs-gateway-sw.js"
) {
console.log("replayed", {
PRIMARY_REGION,
FLY_REGION,
url: req.url,
})
return new Response("replayed", {
headers: {
"fly-replay": `region=${PRIMARY_REGION}`,
},
})
return NextResponse.next()
}
const tenant = await getTenant(req, req.nextUrl.searchParams)
@@ -47,15 +34,9 @@ export default async function middleware(req: NextRequest) {
)
}
if (pathname.startsWith("/api/") || pathname.startsWith("/dashboard")) {
return NextResponse.next()
}
if (tenant?.subdomain) {
const url = req.nextUrl.clone()
if (url.pathname !== "/ipfs-gateway-sw.js") {
url.pathname = `/_site/${tenant?.subdomain}${url.pathname}`
}
url.pathname = `/_site/${tenant?.subdomain}${url.pathname}`
return NextResponse.rewrite(url)
}
+1 -24
View File
@@ -16,30 +16,7 @@ const checkPageSlug = async ({
slug: string
excludePage?: string
siteId: string
}) => {
// if (!slug) {
// throw new Error("Missing page slug")
// }
// const page = await prismaPrimary.page.findFirst({
// where: {
// siteId,
// slug,
// id: excludePage && {
// not: excludePage,
// },
// },
// })
// if (!page) return
// if (page.deletedAt) {
// await prismaPrimary.page.delete({
// where: {
// id: page.id,
// },
// })
// return
// }
// throw new Error("Page slug already used")
}
}) => {}
export async function createOrUpdatePage(input: {
pageId?: string
+1 -20
View File
@@ -10,26 +10,7 @@ export const checkSubdomain = async ({
}: {
subdomain: string
updatingSiteId?: string
}) => {
// checkReservedWords(subdomain)
// const existingSite = await prismaPrimary.site.findUnique({
// where: {
// subdomain,
// },
// })
// if (existingSite?.deletedAt) {
// // Actuall delete the site so that the subdomain can be used again
// await prismaPrimary.site.delete({
// where: {
// id: existingSite.id,
// },
// })
// return
// }
// if (existingSite && (!updatingSiteId || existingSite.id !== updatingSiteId)) {
// throw new Error(`Subdomain already taken`)
// }
}
}) => {}
const expandSite = async (site: Profile) => {
site.navigation = JSON.parse(
+14 -21
View File
@@ -1,16 +1,11 @@
import { Toaster } from "react-hot-toast"
import "~/css/main.css"
import "~/generated/uno.css"
import { StoreProvider, createStore } from "~/lib/store"
import { IpfsGatewayContext } from "@crossbell/ipfs-react"
import { getDefaultWallets, RainbowKitProvider } from "@rainbow-me/rainbowkit"
import { RainbowKitProvider } from "@rainbow-me/rainbowkit"
import { configureChains, createClient, WagmiConfig } from "wagmi"
import { jsonRpcProvider } from "wagmi/providers/jsonRpc"
import {
Hydrate,
QueryClient,
QueryClientProvider,
} from "@tanstack/react-query"
import { Hydrate, QueryClient } from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client"
import { createIDBPersister } from "~/lib/persister.client"
@@ -76,20 +71,18 @@ function MyApp({ Component, pageProps }: any) {
return (
<WagmiConfig client={wagmiClient}>
<RainbowKitProvider chains={chains}>
<StoreProvider createStore={createStore}>
<PersistQueryClientProvider
client={queryClient}
persistOptions={{ persister }}
>
<Hydrate state={pageProps.dehydratedState}>
<ReactQueryDevtools />
<IpfsGatewayContext.Provider value={ipfsGateway}>
{getLayout(<Component {...pageProps} />)}
</IpfsGatewayContext.Provider>
<Toaster />
</Hydrate>
</PersistQueryClientProvider>
</StoreProvider>
<PersistQueryClientProvider
client={queryClient}
persistOptions={{ persister }}
>
<Hydrate state={pageProps.dehydratedState}>
<ReactQueryDevtools />
<IpfsGatewayContext.Provider value={ipfsGateway}>
{getLayout(<Component {...pageProps} />)}
</IpfsGatewayContext.Provider>
<Toaster />
</Hydrate>
</PersistQueryClientProvider>
</RainbowKitProvider>
</WagmiConfig>
)
-12
View File
@@ -1,12 +0,0 @@
import { NextRequest, NextResponse } from "next/server"
import { AUTH_COOKIE_NAME } from "~/lib/env.server"
export default function middleware(req: NextRequest) {
// Redirect unauthenticated users to the home page
// if (!req.cookies[AUTH_COOKIE_NAME]) {
// const url = req.nextUrl.clone()
// url.pathname = "/"
// return NextResponse.redirect(url)
// }
return NextResponse.next()
}
+1 -1
View File
@@ -160,7 +160,7 @@ export default function NewSitePage() {
href="https://faucet.crossbell.io/"
className="font-bold text-red-500"
>
our faucet
Crossbell faucet
</UniLink>{" "}
to get some free $CSB.
</p>
+2 -5
View File
@@ -4,11 +4,9 @@ import { DashboardIcon } from "~/components/icons/DashboardIcon"
import { MainLayout } from "~/components/main/MainLayout"
import { UniLink } from "~/components/ui/UniLink"
import { FLY_REGION } from "~/lib/env.server"
import { useStore } from "~/lib/store"
import { useAccount } from "wagmi"
import { ConnectButton } from "~/components/common/ConnectButton"
import Image from "next/image"
import { DotsHorizontalIcon, CheckIcon, XIcon } from "@heroicons/react/solid"
import { EllipsisHorizontalIcon } from "@heroicons/react/20/solid"
import { LoveIcon } from "~/components/icons/LoveIcon"
import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
import { Button } from "~/components/ui/Button"
@@ -27,7 +25,6 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
}
export default function Home({ region }: { region: string | null }) {
const setLoginModalOpened = useStore((store) => store.setLoginModalOpened)
const [addressIn, setAddressIn] = useState<string>("")
const { address } = useAccount()
const { openConnectModal } = useConnectModal()
@@ -218,7 +215,7 @@ export default function Home({ region }: { region: string | null }) {
</li>
<li className="inline-flex h-5 align-middle items-center">
<UniLink className="inline-block" href="#">
<DotsHorizontalIcon className="w-4 h-4" />
<EllipsisHorizontalIcon className="w-4 h-4" />
</UniLink>
</li>
</ul>
+3
View File
@@ -12,6 +12,9 @@ export const useGetPagesBySite = (
export const useGetPage = (input: Parameters<typeof pageModel.getPage>[0]) => {
return useQuery(["getPage", input.page, input], async () => {
if (!input.site || !(input.page || input.pageId)) {
return null
}
return pageModel.getPage(input)
})
}