diff --git a/client/components/auth/auth.module.css b/client/app/(auth)/components/auth.module.css similarity index 100% rename from client/components/auth/auth.module.css rename to client/app/(auth)/components/auth.module.css diff --git a/client/components/auth/index.tsx b/client/app/(auth)/components/index.tsx similarity index 98% rename from client/components/auth/index.tsx rename to client/app/(auth)/components/index.tsx index b5b0fd34..dd7af02a 100644 --- a/client/components/auth/index.tsx +++ b/client/app/(auth)/components/index.tsx @@ -3,7 +3,7 @@ import { FormEvent, useState } from "react" import styles from "./auth.module.css" import { useRouter } from "next/navigation" -import Link from "../link" +import Link from "../../components/link" import { Button, Input, Note } from "@geist-ui/core/dist" import { signIn } from "next-auth/react" import { Github as GithubIcon } from "@geist-ui/icons" diff --git a/client/app/(auth)/head.tsx b/client/app/(auth)/signin/head.tsx similarity index 62% rename from client/app/(auth)/head.tsx rename to client/app/(auth)/signin/head.tsx index 6a70b7ad..1110d61b 100644 --- a/client/app/(auth)/head.tsx +++ b/client/app/(auth)/signin/head.tsx @@ -1,4 +1,4 @@ -import PageSeo from "@components/page-seo" +import PageSeo from "app/components/page-seo" export default function AuthHead() { return diff --git a/client/app/(auth)/signin/page.tsx b/client/app/(auth)/signin/page.tsx index 71ff0f86..495eb6d2 100644 --- a/client/app/(auth)/signin/page.tsx +++ b/client/app/(auth)/signin/page.tsx @@ -1,5 +1,5 @@ -import Auth from "@components/auth" -import Header from "@components/header" +import Auth from "../components" +import Header from "app/components/header" export default function SignInPage() { return ( diff --git a/client/app/(auth)/signup/head.tsx b/client/app/(auth)/signup/head.tsx new file mode 100644 index 00000000..907f08c7 --- /dev/null +++ b/client/app/(auth)/signup/head.tsx @@ -0,0 +1,5 @@ +import PageSeo from "app/components/page-seo" + +export default function AuthHead() { + return +} diff --git a/client/app/(auth)/signup/page.tsx b/client/app/(auth)/signup/page.tsx index 2584d0be..deba8ab5 100644 --- a/client/app/(auth)/signup/page.tsx +++ b/client/app/(auth)/signup/page.tsx @@ -1,5 +1,5 @@ -import Auth from "@components/auth" -import Header from "@components/header" +import Auth from "../components" +import Header from "app/components/header" import { getRequiresPasscode } from "pages/api/auth/requires-passcode" const getPasscode = async () => { diff --git a/client/components/file-dropdown/dropdown.module.css b/client/app/(posts)/components/file-dropdown/dropdown.module.css similarity index 100% rename from client/components/file-dropdown/dropdown.module.css rename to client/app/(posts)/components/file-dropdown/dropdown.module.css diff --git a/client/components/file-dropdown/index.tsx b/client/app/(posts)/components/file-dropdown/index.tsx similarity index 97% rename from client/components/file-dropdown/index.tsx rename to client/app/(posts)/components/file-dropdown/index.tsx index e299b3e1..ab0f6dc5 100644 --- a/client/components/file-dropdown/index.tsx +++ b/client/app/(posts)/components/file-dropdown/index.tsx @@ -1,4 +1,4 @@ -import ShiftBy from "@components/shift-by" +import ShiftBy from "app/components/shift-by" import { Button, Popover } from "@geist-ui/core/dist" import ChevronDown from "@geist-ui/icons/chevronDown" import CodeIcon from "@geist-ui/icons/fileFunction" diff --git a/client/components/file-tree/file-tree.module.css b/client/app/(posts)/components/file-tree/file-tree.module.css similarity index 100% rename from client/components/file-tree/file-tree.module.css rename to client/app/(posts)/components/file-tree/file-tree.module.css diff --git a/client/components/file-tree/index.tsx b/client/app/(posts)/components/file-tree/index.tsx similarity index 94% rename from client/components/file-tree/index.tsx rename to client/app/(posts)/components/file-tree/index.tsx index c6cf04e1..af21953f 100644 --- a/client/components/file-tree/index.tsx +++ b/client/app/(posts)/components/file-tree/index.tsx @@ -2,10 +2,10 @@ import { File } from "@lib/types" import FileIcon from "@geist-ui/icons/fileText" import CodeIcon from "@geist-ui/icons/fileLambda" import styles from "./file-tree.module.css" -import ShiftBy from "@components/shift-by" +import ShiftBy from "app/components/shift-by" import { useEffect, useState } from "react" import { codeFileExtensions } from "@lib/constants" -import Link from "@components/link" +import Link from "app/components/link" type Item = File & { icon: JSX.Element diff --git a/client/components/new-post/description/index.tsx b/client/app/(posts)/new/components/description/index.tsx similarity index 100% rename from client/components/new-post/description/index.tsx rename to client/app/(posts)/new/components/description/index.tsx diff --git a/client/components/new-post/drag-and-drop/drag-and-drop.module.css b/client/app/(posts)/new/components/drag-and-drop/drag-and-drop.module.css similarity index 100% rename from client/components/new-post/drag-and-drop/drag-and-drop.module.css rename to client/app/(posts)/new/components/drag-and-drop/drag-and-drop.module.css diff --git a/client/components/new-post/drag-and-drop/index.tsx b/client/app/(posts)/new/components/drag-and-drop/index.tsx similarity index 100% rename from client/components/new-post/drag-and-drop/index.tsx rename to client/app/(posts)/new/components/drag-and-drop/index.tsx diff --git a/client/components/edit-document/document.module.css b/client/app/(posts)/new/components/edit-document-list/edit-document/document.module.css similarity index 100% rename from client/components/edit-document/document.module.css rename to client/app/(posts)/new/components/edit-document-list/edit-document/document.module.css diff --git a/client/components/edit-document/formatting-icons/index.tsx b/client/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx similarity index 100% rename from client/components/edit-document/formatting-icons/index.tsx rename to client/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx diff --git a/client/components/edit-document/index.tsx b/client/app/(posts)/new/components/edit-document-list/edit-document/index.tsx similarity index 98% rename from client/components/edit-document/index.tsx rename to client/app/(posts)/new/components/edit-document-list/edit-document/index.tsx index cdb29d69..ea57157b 100644 --- a/client/components/edit-document/index.tsx +++ b/client/app/(posts)/new/components/edit-document-list/edit-document/index.tsx @@ -12,7 +12,7 @@ import FormattingIcons from "./formatting-icons" import TextareaMarkdown, { TextareaMarkdownRef } from "textarea-markdown-editor" import { Button, Input, Spacer, Tabs, Textarea } from "@geist-ui/core/dist" -import Preview from "@components/preview" +import Preview from "./preview" // import Link from "next/link" type Props = { diff --git a/client/components/preview/index.tsx b/client/app/(posts)/new/components/edit-document-list/edit-document/preview/index.tsx similarity index 85% rename from client/components/preview/index.tsx rename to client/app/(posts)/new/components/edit-document-list/edit-document/preview/index.tsx index 81429e78..3ab0fb3a 100644 --- a/client/components/preview/index.tsx +++ b/client/app/(posts)/new/components/edit-document-list/edit-document/preview/index.tsx @@ -8,7 +8,6 @@ type Props = { fileId?: string content?: string title?: string - // file extensions we can highlight } const MarkdownPreview = ({ height = 500, fileId, content, title }: Props) => { @@ -26,18 +25,13 @@ const MarkdownPreview = ({ height = 500, fileId, content, title }: Props) => { setIsLoading(false) } } else if (content) { - // add title and query to url params const urlQuery = new URLSearchParams({ title: title || "", content }) const resp = await fetch(`/api/files/get-html?${urlQuery}`, { - method: "GET", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${getCookie(TOKEN_COOKIE_NAME)}` - } + method: "GET" }) if (resp.ok) { diff --git a/client/components/preview/preview.module.css b/client/app/(posts)/new/components/edit-document-list/edit-document/preview/preview.module.css similarity index 100% rename from client/components/preview/preview.module.css rename to client/app/(posts)/new/components/edit-document-list/edit-document/preview/preview.module.css diff --git a/client/components/edit-document-list/index.tsx b/client/app/(posts)/new/components/edit-document-list/index.tsx similarity index 94% rename from client/components/edit-document-list/index.tsx rename to client/app/(posts)/new/components/edit-document-list/index.tsx index 69af06aa..d51b8cb3 100644 --- a/client/components/edit-document-list/index.tsx +++ b/client/app/(posts)/new/components/edit-document-list/index.tsx @@ -1,5 +1,5 @@ import type { Document } from "@lib/types" -import DocumentComponent from "@components/edit-document" +import DocumentComponent from "./edit-document" import { ChangeEvent, memo, useCallback } from "react" const DocumentList = ({ diff --git a/client/components/new-post/index.tsx b/client/app/(posts)/new/components/new.tsx similarity index 98% rename from client/components/new-post/index.tsx rename to client/app/(posts)/new/components/new.tsx index 88fef11a..cb65dfae 100644 --- a/client/components/new-post/index.tsx +++ b/client/app/(posts)/new/components/new.tsx @@ -4,17 +4,16 @@ import { Button, useToasts, Input, ButtonDropdown } from "@geist-ui/core/dist" import { useRouter } from "next/navigation" import { useCallback, useState } from "react" import generateUUID from "@lib/generate-uuid" -import FileDropzone from "./drag-and-drop" import styles from "./post.module.css" -import Title from "./title" import type { PostVisibility, Document as DocumentType } from "@lib/types" -import PasswordModal from "./password-modal" -import EditDocumentList from "@components/edit-document-list" +import EditDocumentList from "./edit-document-list" import { ChangeEvent } from "react" import DatePicker from "react-datepicker" import getTitleForPostCopy from "@lib/get-title-for-post-copy" import Description from "./description" import { PostWithFiles } from "@lib/server/prisma" +import PasswordModal from "./password-modal" +import Title from "./title" const emptyDoc = { title: "", diff --git a/client/components/new-post/password-modal/index.tsx b/client/app/(posts)/new/components/password-modal/index.tsx similarity index 100% rename from client/components/new-post/password-modal/index.tsx rename to client/app/(posts)/new/components/password-modal/index.tsx diff --git a/client/components/new-post/post.module.css b/client/app/(posts)/new/components/post.module.css similarity index 100% rename from client/components/new-post/post.module.css rename to client/app/(posts)/new/components/post.module.css diff --git a/client/components/new-post/title/index.tsx b/client/app/(posts)/new/components/title/index.tsx similarity index 96% rename from client/components/new-post/title/index.tsx rename to client/app/(posts)/new/components/title/index.tsx index 7e781081..f78eee26 100644 --- a/client/components/new-post/title/index.tsx +++ b/client/app/(posts)/new/components/title/index.tsx @@ -1,7 +1,7 @@ import { ChangeEvent, memo, useEffect, useState } from "react" import { Text } from "@geist-ui/core/dist" -import ShiftBy from "@components/shift-by" +import ShiftBy from "app/components/shift-by" import styles from "../post.module.css" import { Input } from "@geist-ui/core/dist" diff --git a/client/app/(posts)/new/from/[id]/page.tsx b/client/app/(posts)/new/from/[id]/page.tsx index 47e6ee66..57c95481 100644 --- a/client/app/(posts)/new/from/[id]/page.tsx +++ b/client/app/(posts)/new/from/[id]/page.tsx @@ -1,7 +1,7 @@ -import NewPost from "@components/new-post" +import NewPost from "app/(posts)/new/components/new" import { useRouter } from "next/navigation" import { getPostWithFiles } from "@lib/server/prisma" -import Header from "@components/header" +import Header from "app/components/header" const NewFromExisting = async ({ params diff --git a/client/app/(posts)/new/head.tsx b/client/app/(posts)/new/head.tsx index 8acc8e7d..1dc76900 100644 --- a/client/app/(posts)/new/head.tsx +++ b/client/app/(posts)/new/head.tsx @@ -1,4 +1,4 @@ -import PageSeo from "@components/page-seo" +import PageSeo from "app/components/page-seo" export default function NewPostHead() { return diff --git a/client/app/(posts)/new/page.tsx b/client/app/(posts)/new/page.tsx index c4570825..4943ba4d 100644 --- a/client/app/(posts)/new/page.tsx +++ b/client/app/(posts)/new/page.tsx @@ -1,5 +1,5 @@ -import Header from "@components/header" -import NewPost from "@components/new-post" +import Header from "app/components/header" +import NewPost from "app/(posts)/new/components/new" import "@styles/react-datepicker.css" const New = () => <> diff --git a/client/components/post-page/index.tsx b/client/app/(posts)/post/[id]/components/post-page/index.tsx similarity index 89% rename from client/components/post-page/index.tsx rename to client/app/(posts)/post/[id]/components/post-page/index.tsx index 40b6e8fc..d30f1d38 100644 --- a/client/components/post-page/index.tsx +++ b/client/app/(posts)/post/[id]/components/post-page/index.tsx @@ -1,7 +1,7 @@ "use client" -import VisibilityBadge from "@components/badges/visibility-badge" -import DocumentComponent from "@components/view-document" +import VisibilityBadge from "app/components/badges/visibility-badge" +import DocumentComponent from "./view-document" import styles from "./post-page.module.css" import type { PostVisibility } from "@lib/types" @@ -10,15 +10,15 @@ import { useEffect, useState } from "react" import Archive from "@geist-ui/icons/archive" import Edit from "@geist-ui/icons/edit" import Parent from "@geist-ui/icons/arrowUpCircle" -import FileDropdown from "@components/file-dropdown" -import ScrollToTop from "@components/scroll-to-top" +import FileDropdown from "app/(posts)/components/file-dropdown" +import ScrollToTop from "app/components/scroll-to-top" import { useRouter } from "next/navigation" -import ExpirationBadge from "@components/badges/expiration-badge" -import CreatedAgoBadge from "@components/badges/created-ago-badge" +import ExpirationBadge from "app/components/badges/expiration-badge" +import CreatedAgoBadge from "app/components/badges/created-ago-badge" import PasswordModalPage from "./password-modal-wrapper" -import VisibilityControl from "@components/badges/visibility-control" +import VisibilityControl from "app/components/badges/visibility-control" import { File, PostWithFiles } from "@lib/server/prisma" -import Header from "@components/header" +import Header from "app/components/header" type Props = { post: PostWithFiles diff --git a/client/components/post-page/password-modal-wrapper.tsx b/client/app/(posts)/post/[id]/components/post-page/password-modal-wrapper.tsx similarity index 100% rename from client/components/post-page/password-modal-wrapper.tsx rename to client/app/(posts)/post/[id]/components/post-page/password-modal-wrapper.tsx diff --git a/client/components/post-page/post-page.module.css b/client/app/(posts)/post/[id]/components/post-page/post-page.module.css similarity index 100% rename from client/components/post-page/post-page.module.css rename to client/app/(posts)/post/[id]/components/post-page/post-page.module.css diff --git a/client/components/view-document/document.module.css b/client/app/(posts)/post/[id]/components/post-page/view-document/document.module.css similarity index 100% rename from client/components/view-document/document.module.css rename to client/app/(posts)/post/[id]/components/post-page/view-document/document.module.css diff --git a/client/components/view-document/index.tsx b/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx similarity index 96% rename from client/components/view-document/index.tsx rename to client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx index c6e9bbe3..34c8d808 100644 --- a/client/components/view-document/index.tsx +++ b/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx @@ -14,8 +14,8 @@ import { Tooltip, Tag } from "@geist-ui/core/dist" -import HtmlPreview from "@components/preview" -import FadeIn from "@components/fade-in" +import HtmlPreview from "app/(posts)/new/components/edit-document-list/edit-document/preview" +import FadeIn from "app/components/fade-in" // import Link from "next/link" type Props = { diff --git a/client/app/(posts)/post/[id]/head.tsx b/client/app/(posts)/post/[id]/head.tsx index 1d175a2d..ec347ddf 100644 --- a/client/app/(posts)/post/[id]/head.tsx +++ b/client/app/(posts)/post/[id]/head.tsx @@ -1,4 +1,4 @@ -import PageSeo from "@components/page-seo" +import PageSeo from "app/components/page-seo" import { getPostById } from "@lib/server/prisma" export default async function Head({ diff --git a/client/app/(posts)/post/[id]/page.tsx b/client/app/(posts)/post/[id]/page.tsx index f1afc71e..716564ab 100644 --- a/client/app/(posts)/post/[id]/page.tsx +++ b/client/app/(posts)/post/[id]/page.tsx @@ -1,12 +1,12 @@ import type { GetServerSideProps } from "next" import type { Post } from "@lib/types" -import PostPage from "@components/post-page" +import PostPage from "app/(posts)/post/[id]/components/post-page" import { USER_COOKIE_NAME } from "@lib/constants" import { notFound } from "next/navigation" import { getPostById } from "@lib/server/prisma" import { getCurrentUser, getSession } from "@lib/server/session" -import Header from "@components/header" +import Header from "app/components/header" export type PostProps = { post: Post diff --git a/client/components/admin/action-dropdown/index.tsx b/client/app/admin/components/action-dropdown/index.tsx similarity index 100% rename from client/components/admin/action-dropdown/index.tsx rename to client/app/admin/components/action-dropdown/index.tsx diff --git a/client/components/admin/admin.module.css b/client/app/admin/components/admin.module.css similarity index 100% rename from client/components/admin/admin.module.css rename to client/app/admin/components/admin.module.css diff --git a/client/components/admin/index.tsx b/client/app/admin/components/admin.tsx similarity index 100% rename from client/components/admin/index.tsx rename to client/app/admin/components/admin.tsx diff --git a/client/components/admin/post-table.tsx b/client/app/admin/components/post-table.tsx similarity index 98% rename from client/components/admin/post-table.tsx rename to client/app/admin/components/post-table.tsx index 312575bf..0fff6b49 100644 --- a/client/components/admin/post-table.tsx +++ b/client/app/admin/components/post-table.tsx @@ -4,7 +4,7 @@ import byteToMB from "@lib/byte-to-mb" import { Post } from "@lib/types" import Table from "rc-table" import { useEffect, useMemo, useState } from "react" -import { adminFetcher } from "." +import { adminFetcher } from "./admin" import ActionDropdown from "./action-dropdown" const PostTable = () => { diff --git a/client/components/admin/user-table.tsx b/client/app/admin/components/user-table.tsx similarity index 98% rename from client/components/admin/user-table.tsx rename to client/app/admin/components/user-table.tsx index 12ef0d22..4d3a157c 100644 --- a/client/components/admin/user-table.tsx +++ b/client/app/admin/components/user-table.tsx @@ -1,7 +1,7 @@ import { Fieldset, useToasts } from "@geist-ui/core/dist" import { User } from "@lib/types" import { useEffect, useMemo, useState } from "react" -import { adminFetcher } from "." +import { adminFetcher } from "./admin" import Table from "rc-table" import SettingsGroup from "@components/settings-group" import ActionDropdown from "./action-dropdown" diff --git a/client/app/admin/page.tsx b/client/app/admin/page.tsx index ffba5bc1..9ed2299f 100644 --- a/client/app/admin/page.tsx +++ b/client/app/admin/page.tsx @@ -1,8 +1,5 @@ -import Admin from "@components/admin" -import { TOKEN_COOKIE_NAME } from "@lib/constants" -import { isUserAdmin } from "@lib/server/prisma" +import Admin from "./components/admin" import { getCurrentUser } from "@lib/server/session" -import { cookies } from "next/headers" import { notFound } from "next/navigation" const AdminPage = async () => { diff --git a/client/components/badges/created-ago-badge/index.tsx b/client/app/components/badges/created-ago-badge/index.tsx similarity index 100% rename from client/components/badges/created-ago-badge/index.tsx rename to client/app/components/badges/created-ago-badge/index.tsx diff --git a/client/components/badges/expiration-badge/index.tsx b/client/app/components/badges/expiration-badge/index.tsx similarity index 100% rename from client/components/badges/expiration-badge/index.tsx rename to client/app/components/badges/expiration-badge/index.tsx diff --git a/client/components/badges/visibility-badge/index.tsx b/client/app/components/badges/visibility-badge/index.tsx similarity index 100% rename from client/components/badges/visibility-badge/index.tsx rename to client/app/components/badges/visibility-badge/index.tsx diff --git a/client/components/badges/visibility-control/index.tsx b/client/app/components/badges/visibility-control/index.tsx similarity index 100% rename from client/components/badges/visibility-control/index.tsx rename to client/app/components/badges/visibility-control/index.tsx diff --git a/client/components/button-dropdown/dropdown.module.css b/client/app/components/button-dropdown/dropdown.module.css similarity index 100% rename from client/components/button-dropdown/dropdown.module.css rename to client/app/components/button-dropdown/dropdown.module.css diff --git a/client/components/button-dropdown/index.tsx b/client/app/components/button-dropdown/index.tsx similarity index 100% rename from client/components/button-dropdown/index.tsx rename to client/app/components/button-dropdown/index.tsx diff --git a/client/components/button/button.module.css b/client/app/components/button/button.module.css similarity index 100% rename from client/components/button/button.module.css rename to client/app/components/button/button.module.css diff --git a/client/components/button/index.tsx b/client/app/components/button/index.tsx similarity index 100% rename from client/components/button/index.tsx rename to client/app/components/button/index.tsx diff --git a/client/components/error/index.tsx b/client/app/components/error/index.tsx similarity index 100% rename from client/components/error/index.tsx rename to client/app/components/error/index.tsx diff --git a/client/components/fade-in/fade.module.css b/client/app/components/fade-in/fade.module.css similarity index 100% rename from client/components/fade-in/fade.module.css rename to client/app/components/fade-in/fade.module.css diff --git a/client/components/fade-in/index.tsx b/client/app/components/fade-in/index.tsx similarity index 100% rename from client/components/fade-in/index.tsx rename to client/app/components/fade-in/index.tsx diff --git a/client/components/header/controls.tsx b/client/app/components/header/controls.tsx similarity index 100% rename from client/components/header/controls.tsx rename to client/app/components/header/controls.tsx diff --git a/client/components/header/header.module.css b/client/app/components/header/header.module.css similarity index 100% rename from client/components/header/header.module.css rename to client/app/components/header/header.module.css diff --git a/client/components/header/index.tsx b/client/app/components/header/index.tsx similarity index 98% rename from client/components/header/index.tsx rename to client/app/components/header/index.tsx index b7a2582a..9345edf2 100644 --- a/client/components/header/index.tsx +++ b/client/app/components/header/index.tsx @@ -27,6 +27,7 @@ import { useTheme } from "next-themes" // import useUserData from "@lib/hooks/use-user-data" import Link from "next/link" import { usePathname } from "next/navigation" +import { signOut } from "next-auth/react" type Tab = { name: string @@ -99,7 +100,7 @@ const Header = ({ signedIn = false }) => { name: "sign out", icon: , value: "signout", - href: "/signout" + onClick: () => signOut() }, ...defaultPages ]) @@ -220,4 +221,4 @@ const Header = ({ signedIn = false }) => { ) } -export default Header \ No newline at end of file +export default Header diff --git a/client/app/(home)/home.module.css b/client/app/components/home.module.css similarity index 100% rename from client/app/(home)/home.module.css rename to client/app/components/home.module.css diff --git a/client/app/(home)/home.tsx b/client/app/components/home.tsx similarity index 97% rename from client/app/(home)/home.tsx rename to client/app/components/home.tsx index ede2d77b..bd41652f 100644 --- a/client/app/(home)/home.tsx +++ b/client/app/components/home.tsx @@ -1,5 +1,5 @@ "use client" -import ShiftBy from "@components/shift-by" +import ShiftBy from "app/components/shift-by" import { Spacer, Tabs, Card, Textarea, Text } from "@geist-ui/core/dist" import Image from "next/image" import styles from "./home.module.css" diff --git a/client/components/input/index.tsx b/client/app/components/input/index.tsx similarity index 100% rename from client/components/input/index.tsx rename to client/app/components/input/index.tsx diff --git a/client/components/input/input.module.css b/client/app/components/input/input.module.css similarity index 100% rename from client/components/input/input.module.css rename to client/app/components/input/input.module.css diff --git a/client/components/link/index.tsx b/client/app/components/link/index.tsx similarity index 100% rename from client/components/link/index.tsx rename to client/app/components/link/index.tsx diff --git a/client/components/link/link.module.css b/client/app/components/link/link.module.css similarity index 100% rename from client/components/link/link.module.css rename to client/app/components/link/link.module.css diff --git a/client/components/note/index.tsx b/client/app/components/note/index.tsx similarity index 100% rename from client/components/note/index.tsx rename to client/app/components/note/index.tsx diff --git a/client/components/note/note.module.css b/client/app/components/note/note.module.css similarity index 100% rename from client/components/note/note.module.css rename to client/app/components/note/note.module.css diff --git a/client/components/page-seo/index.tsx b/client/app/components/page-seo/index.tsx similarity index 100% rename from client/components/page-seo/index.tsx rename to client/app/components/page-seo/index.tsx diff --git a/client/components/post-list/index.tsx b/client/app/components/post-list/index.tsx similarity index 99% rename from client/components/post-list/index.tsx rename to client/app/components/post-list/index.tsx index 9fa80784..049fb77b 100644 --- a/client/components/post-list/index.tsx +++ b/client/app/components/post-list/index.tsx @@ -7,7 +7,7 @@ import ListItemSkeleton from "./list-item-skeleton" import ListItem from "./list-item" import { ChangeEvent, useCallback, useEffect, useState } from "react" import useDebounce from "@lib/hooks/use-debounce" -import Link from "@components/link" +import Link from "app/components/link" import { TOKEN_COOKIE_NAME } from "@lib/constants" import { getCookie } from "cookies-next" import type { PostWithFiles } from "@lib/server/prisma" diff --git a/client/components/post-list/list-item-skeleton.tsx b/client/app/components/post-list/list-item-skeleton.tsx similarity index 100% rename from client/components/post-list/list-item-skeleton.tsx rename to client/app/components/post-list/list-item-skeleton.tsx diff --git a/client/components/post-list/list-item.module.css b/client/app/components/post-list/list-item.module.css similarity index 100% rename from client/components/post-list/list-item.module.css rename to client/app/components/post-list/list-item.module.css diff --git a/client/components/post-list/list-item.tsx b/client/app/components/post-list/list-item.tsx similarity index 91% rename from client/components/post-list/list-item.tsx rename to client/app/components/post-list/list-item.tsx index 012638e3..a4c06e80 100644 --- a/client/components/post-list/list-item.tsx +++ b/client/app/components/post-list/list-item.tsx @@ -7,15 +7,15 @@ import { Badge, Button } from "@geist-ui/core/dist" -import FadeIn from "@components/fade-in" +import FadeIn from "app/components/fade-in" import Trash from "@geist-ui/icons/trash" -import ExpirationBadge from "@components/badges/expiration-badge" -import CreatedAgoBadge from "@components/badges/created-ago-badge" +import ExpirationBadge from "app/components/badges/expiration-badge" +import CreatedAgoBadge from "app/components/badges/created-ago-badge" import Edit from "@geist-ui/icons/edit" import { useRouter } from "next/navigation" import Parent from "@geist-ui/icons/arrowUpCircle" import styles from "./list-item.module.css" -import Link from "@components/link" +import Link from "app/components/link" import type { PostWithFiles } from "@lib/server/prisma" import type { PostVisibility } from "@lib/types" import type { File } from "@lib/server/prisma" @@ -40,10 +40,6 @@ const ListItem = ({ router.push(`/post/${post.parentId}`) } - { - console.log(post) - } - return (
  • diff --git a/client/components/post-list/post-list.module.css b/client/app/components/post-list/post-list.module.css similarity index 100% rename from client/components/post-list/post-list.module.css rename to client/app/components/post-list/post-list.module.css diff --git a/client/components/scroll-to-top/index.tsx b/client/app/components/scroll-to-top/index.tsx similarity index 100% rename from client/components/scroll-to-top/index.tsx rename to client/app/components/scroll-to-top/index.tsx diff --git a/client/components/scroll-to-top/scroll.module.css b/client/app/components/scroll-to-top/scroll.module.css similarity index 100% rename from client/components/scroll-to-top/scroll.module.css rename to client/app/components/scroll-to-top/scroll.module.css diff --git a/client/components/shift-by.tsx b/client/app/components/shift-by.tsx similarity index 100% rename from client/components/shift-by.tsx rename to client/app/components/shift-by.tsx diff --git a/client/app/(profiles)/mine/head.tsx b/client/app/mine/head.tsx similarity index 67% rename from client/app/(profiles)/mine/head.tsx rename to client/app/mine/head.tsx index 8b9fc207..cf5f536a 100644 --- a/client/app/(profiles)/mine/head.tsx +++ b/client/app/mine/head.tsx @@ -1,4 +1,4 @@ -import PageSeo from "@components/page-seo" +import PageSeo from "app/components/page-seo" export default function Head() { return diff --git a/client/app/(profiles)/mine/page.tsx b/client/app/mine/page.tsx similarity index 85% rename from client/app/(profiles)/mine/page.tsx rename to client/app/mine/page.tsx index f35be304..38fdee1f 100644 --- a/client/app/(profiles)/mine/page.tsx +++ b/client/app/mine/page.tsx @@ -1,8 +1,8 @@ import { redirect } from "next/navigation" import { getPostsByUser } from "@lib/server/prisma" -import PostList from "@components/post-list" +import PostList from "app/components/post-list" import { getCurrentUser } from "@lib/server/session" -import Header from "@components/header" +import Header from "app/components/header" import { authOptions } from "@lib/server/auth" export default async function Mine() { diff --git a/client/app/(home)/page.tsx b/client/app/page.tsx similarity index 86% rename from client/app/(home)/page.tsx rename to client/app/page.tsx index 4f6f911f..bf787a56 100644 --- a/client/app/(home)/page.tsx +++ b/client/app/page.tsx @@ -1,7 +1,7 @@ -import Header from "@components/header" +import Header from "app/components/header" import { getCurrentUser } from "@lib/server/session" import { getWelcomeContent } from "pages/api/welcome" -import Home from "./home" +import Home from "./components/home" const getWelcomeData = async () => { const welcomeContent = await getWelcomeContent() @@ -11,7 +11,7 @@ const getWelcomeData = async () => { export default async function Page() { const { content, rendered, title } = await getWelcomeData() const authed = await getCurrentUser(); - + return ( <>
    diff --git a/client/components/settings/sections/password.tsx b/client/app/settings/components/sections/password.tsx similarity index 100% rename from client/components/settings/sections/password.tsx rename to client/app/settings/components/sections/password.tsx diff --git a/client/components/settings/sections/profile.tsx b/client/app/settings/components/sections/profile.tsx similarity index 100% rename from client/components/settings/sections/profile.tsx rename to client/app/settings/components/sections/profile.tsx diff --git a/client/components/settings-group/index.tsx b/client/app/settings/components/settings-group/index.tsx similarity index 100% rename from client/components/settings-group/index.tsx rename to client/app/settings/components/settings-group/index.tsx diff --git a/client/components/settings-group/settings-group.module.css b/client/app/settings/components/settings-group/settings-group.module.css similarity index 100% rename from client/components/settings-group/settings-group.module.css rename to client/app/settings/components/settings-group/settings-group.module.css diff --git a/client/app/(profiles)/settings/head.tsx b/client/app/settings/head.tsx similarity index 66% rename from client/app/(profiles)/settings/head.tsx rename to client/app/settings/head.tsx index 6404a743..ae3f2488 100644 --- a/client/app/(profiles)/settings/head.tsx +++ b/client/app/settings/head.tsx @@ -1,4 +1,4 @@ -import PageSeo from "@components/page-seo" +import PageSeo from "app/components/page-seo" export default function Head() { return diff --git a/client/app/(profiles)/settings/page.tsx b/client/app/settings/page.tsx similarity index 74% rename from client/app/(profiles)/settings/page.tsx rename to client/app/settings/page.tsx index 4d7fc8fd..76126f79 100644 --- a/client/app/(profiles)/settings/page.tsx +++ b/client/app/settings/page.tsx @@ -1,7 +1,7 @@ -import Header from "@components/header" -import SettingsGroup from "@components/settings-group" -import Password from "@components/settings/sections/password" -import Profile from "@components/settings/sections/profile" +import Header from "app/components/header" +import SettingsGroup from "./components/settings-group" +import Password from "app/settings/components/sections/password" +import Profile from "app/settings/components/sections/profile" import { authOptions } from "@lib/server/auth" import { getCurrentUser } from "@lib/server/session" import { redirect } from "next/navigation" diff --git a/client/styles/Home.module.css b/client/app/styles/Home.module.css similarity index 100% rename from client/styles/Home.module.css rename to client/app/styles/Home.module.css diff --git a/client/styles/globals.css b/client/app/styles/globals.css similarity index 100% rename from client/styles/globals.css rename to client/app/styles/globals.css diff --git a/client/styles/inter.css b/client/app/styles/inter.css similarity index 100% rename from client/styles/inter.css rename to client/app/styles/inter.css diff --git a/client/styles/markdown.css b/client/app/styles/markdown.css similarity index 100% rename from client/styles/markdown.css rename to client/app/styles/markdown.css diff --git a/client/styles/react-datepicker.css b/client/app/styles/react-datepicker.css similarity index 100% rename from client/styles/react-datepicker.css rename to client/app/styles/react-datepicker.css diff --git a/client/styles/syntax.css b/client/app/styles/syntax.css similarity index 100% rename from client/styles/syntax.css rename to client/app/styles/syntax.css diff --git a/client/components/app/index.tsx b/client/components/app/index.tsx deleted file mode 100644 index 943ff951..00000000 --- a/client/components/app/index.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import Header from "@components/header" -import { GeistProvider, CssBaseline, Themes, Page } from "@geist-ui/core/dist" -import type { NextComponentType, NextPageContext } from "next" -import { SkeletonTheme } from "react-loading-skeleton" - -const App = ({ - Component, - pageProps -}: { - Component: NextComponentType - pageProps: any -}) => { - const skeletonBaseColor = "var(--light-gray)" - const skeletonHighlightColor = "var(--lighter-gray)" - - const customTheme = Themes.createFromLight({ - type: "custom", - palette: { - background: "var(--bg)", - foreground: "var(--fg)", - accents_1: "var(--lightest-gray)", - accents_2: "var(--lighter-gray)", - accents_3: "var(--light-gray)", - accents_4: "var(--gray)", - accents_5: "var(--darker-gray)", - accents_6: "var(--darker-gray)", - accents_7: "var(--darkest-gray)", - accents_8: "var(--darkest-gray)", - border: "var(--light-gray)", - warning: "var(--warning)" - }, - expressiveness: { - dropdownBoxShadow: "0 0 0 1px var(--light-gray)", - shadowSmall: "0 0 0 1px var(--light-gray)", - shadowLarge: "0 0 0 1px var(--light-gray)", - shadowMedium: "0 0 0 1px var(--light-gray)" - }, - layout: { - gap: "var(--gap)", - gapHalf: "var(--gap-half)", - gapQuarter: "var(--gap-quarter)", - gapNegative: "var(--gap-negative)", - gapHalfNegative: "var(--gap-half-negative)", - gapQuarterNegative: "var(--gap-quarter-negative)", - radius: "var(--radius)" - }, - font: { - mono: "var(--font-mono)", - sans: "var(--font-sans)" - } - }) - return ( - - - -
    - - - - ) -} - -export default App diff --git a/client/lib/server/auth.ts b/client/lib/server/auth.ts index add5d193..8b22069b 100644 --- a/client/lib/server/auth.ts +++ b/client/lib/server/auth.ts @@ -1,14 +1,14 @@ import { PrismaAdapter } from "@next-auth/prisma-adapter" import { NextAuthOptions } from "next-auth" import GitHubProvider from "next-auth/providers/github" -import prisma from "lib/server/prisma" +import prisma from "@lib/server/prisma" import config from "@lib/config" const providers: NextAuthOptions["providers"] = [ GitHubProvider({ clientId: config.GITHUB_CLIENT_ID, clientSecret: config.GITHUB_CLIENT_SECRET - }), + }) ] export const authOptions: NextAuthOptions = { @@ -41,7 +41,7 @@ export const authOptions: NextAuthOptions = { }) if (!dbUser) { - // TODO: user should be defined? + // TODO: user should be defined? should we invalidate/signout? if (user) { token.id = user.id token.role = "user" @@ -59,4 +59,3 @@ export const authOptions: NextAuthOptions = { } } } as const - diff --git a/client/lib/server/generate-access-token.ts b/client/lib/server/generate-access-token.ts deleted file mode 100644 index 27e1cbc5..00000000 --- a/client/lib/server/generate-access-token.ts +++ /dev/null @@ -1,27 +0,0 @@ -import config from "@lib/config" -import { User } from "@prisma/client" -import prisma from "@lib/server/prisma" -import { sign } from "jsonwebtoken" - -export async function generateAndExpireAccessToken(userId: User["id"]) { - const token = sign({ id: userId }, config.jwt_secret, { expiresIn: "2d" }) - - await prisma.authTokens.create({ - data: { - userId: userId, - token: token - } - }) - - // TODO: set expiredReason? - prisma.authTokens.deleteMany({ - where: { - userId: userId, - token: { - not: token - } - } - }) - - return token -} diff --git a/client/lib/server/prisma.ts b/client/lib/server/prisma.ts index 1b887c65..ed1e3289 100644 --- a/client/lib/server/prisma.ts +++ b/client/lib/server/prisma.ts @@ -4,8 +4,6 @@ declare global { import config from "@lib/config" import { Post, PrismaClient, File, User } from "@prisma/client" -import { cache } from "react" -import { generateAndExpireAccessToken } from "./generate-access-token" const prisma = new PrismaClient() @@ -140,23 +138,11 @@ export const createUser = async ( throw new Error("Wrong registration password") } - // const salt = await genSalt(10) - // the first user is the admin const isUserAdminByDefault = config.enable_admin && (await prisma.user.count()) === 0 const userRole = isUserAdminByDefault ? "admin" : "user" - // const user = await prisma.user.create({ - // data: { - // username, - // password: await bcrypt.hash(password, salt), - // role: userRole, - // }, - // }) - - // const token = await generateAndExpireAccessToken(user.id) - return { // user, // token diff --git a/client/pages/_app.tsx b/client/pages/_app.tsx deleted file mode 100644 index 4d5969cc..00000000 --- a/client/pages/_app.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import "@styles/globals.css" -import type { AppProps as NextAppProps } from "next/app" - -import "react-loading-skeleton/dist/skeleton.css" -import Head from "next/head" -import { ThemeProvider } from "next-themes" -import App from "@components/app" -import React from "react" - -type AppProps

    = { - pageProps: P -} & Omit, "pageProps"> - -function MyApp({ Component, pageProps }: AppProps) { - return ( -

    - - - - - - - - - - - - - Drift - - - - -
    - ) -} - -export default MyApp diff --git a/client/pages/_document.tsx b/client/pages/_document.tsx deleted file mode 100644 index 18ca6fe3..00000000 --- a/client/pages/_document.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { CssBaseline } from "@geist-ui/core/dist" -import Document, { - Html, - Head, - Main, - NextScript, - DocumentContext -} from "next/document" - -class MyDocument extends Document { - static async getInitialProps(ctx: DocumentContext) { - const initialProps = await Document.getInitialProps(ctx) - const styles = CssBaseline.flush() - - return { - ...initialProps, - styles: ( - <> - {initialProps.styles} - {styles} - // TODO: Investigate typescript - ) as any - } - } - - render() { - return ( - - - -
    - - - - ) - } -} - -export default MyDocument diff --git a/client/pages/_error.tsx b/client/pages/_error.tsx deleted file mode 100644 index 1796d6cd..00000000 --- a/client/pages/_error.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import ErrorComponent from "@components/error" - -function Error({ statusCode }: { statusCode: number }) { - return -} - -Error.getInitialProps = ({ res, err }: { res: any; err: any }) => { - const statusCode = res ? res.statusCode : err ? err.statusCode : 404 - return { statusCode } -} - -export default Error diff --git a/client/pages/api/auth/signin-backup.ts b/client/pages/api/auth/signin-backup.ts deleted file mode 100644 index 998723a3..00000000 --- a/client/pages/api/auth/signin-backup.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { NextApiRequest, NextApiResponse } from "next" -import prisma from "@lib/server/prisma" -import bcrypt from "bcrypt" -import { signin } from "@lib/server/signin" -import { setCookie } from "cookies-next" -import { TOKEN_COOKIE_NAME, USER_COOKIE_NAME } from "@lib/constants" - -export default async function handler( - req: NextApiRequest, - res: NextApiResponse -) { - const { username, password } = req.body - if (!username || !password) { - return res.status(400).json({ error: "Missing param" }) - } - - const user = await prisma.user.findFirst({ - where: { - username - } - }) - - if (!user || !user.password) { - return res.status(401).json({ error: "Unauthorized" }) - } - - const isPasswordValid = await bcrypt.compare(password, user.password) - if (!isPasswordValid) { - return res.status(401).json({ error: "Unauthorized" }) - } - - const token = await signin(user.id, req, res) - setCookie(TOKEN_COOKIE_NAME, token, { - path: "/", - maxAge: 60 * 60 * 24 * 7, // 1 week - httpOnly: true, - secure: process.env.NODE_ENV === "production", - req, - res - }) - setCookie(USER_COOKIE_NAME, user.id, { - path: "/", - maxAge: 60 * 60 * 24 * 7, // 1 week - httpOnly: true, - secure: process.env.NODE_ENV === "production", - req, - res - }) - - return res.status(201).json({ token: token, userId: user.id }) -} diff --git a/client/pages/api/auth/signup-backup.ts b/client/pages/api/auth/signup-backup.ts deleted file mode 100644 index 87faedd8..00000000 --- a/client/pages/api/auth/signup-backup.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { NextApiRequest, NextApiResponse } from "next" -import { createUser } from "@lib/server/prisma" - -export default async function handler( - req: NextApiRequest, - res: NextApiResponse -) { - const { username, password, serverPassword } = req.body - const { user, token } = await createUser(username, password, serverPassword) - - return res.status(201).json({ token: token, userId: user.id }) -} diff --git a/client/pages/api/file/html/[id].ts b/client/pages/api/file/html/[id].ts index dcc1aa28..8aad9f7b 100644 --- a/client/pages/api/file/html/[id].ts +++ b/client/pages/api/file/html/[id].ts @@ -1,5 +1,5 @@ import { NextApiRequest, NextApiResponse } from "next" -import prisma from "lib/server/prisma" +import prisma from "@lib/server/prisma" import { parseQueryParam } from "@lib/server/parse-query-param" const getRawFile = async (req: NextApiRequest, res: NextApiResponse) => { diff --git a/client/pages/api/post/index.ts b/client/pages/api/post/index.ts index b63d1145..e105f974 100644 --- a/client/pages/api/post/index.ts +++ b/client/pages/api/post/index.ts @@ -9,10 +9,10 @@ import { import { authOptions } from "@lib/server/auth" import { CreatePostSchema } from "@lib/validations/post" import { Post } from "@prisma/client" -import prisma, { getPostById } from "lib/server/prisma" +import prisma, { getPostById } from "@lib/server/prisma" import { NextApiRequest, NextApiResponse } from "next" import { unstable_getServerSession } from "next-auth/next" -import { File } from "lib/server/prisma" +import { File } from "@lib/server/prisma" import * as crypto from "crypto" import { getHtmlFromFile } from "@lib/server/get-html-from-drift-file" import { getSession } from "next-auth/react" diff --git a/client/prisma/schema.prisma b/client/prisma/schema.prisma index f5f64c76..c018046f 100644 --- a/client/prisma/schema.prisma +++ b/client/prisma/schema.prisma @@ -113,7 +113,6 @@ model User { role String? @default("user") password String? @db.Text - @@map("users") } diff --git a/client/tsconfig.json b/client/tsconfig.json index b4a98ecc..071e1e7a 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -39,13 +39,13 @@ "baseUrl": ".", "paths": { "@components/*": [ - "components/*" + "app/components/*" ], "@lib/*": [ "lib/*" ], "@styles/*": [ - "styles/*" + "app/styles/*" ] } },