- 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/*"
]
}
},