diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..87688e7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules/ +.next/ +uploads/ +.git/ diff --git a/.gitignore b/.gitignore index 535aadd..f09f4c3 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ # misc .DS_Store *.pem +.idea # debug npm-debug.log* @@ -35,5 +36,4 @@ yarn-error.log* # zipline config.toml -uploads/ -data.db* \ No newline at end of file +uploads/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index fb127d1..db5c5c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM node:16-alpine3.11 AS builder WORKDIR /build +ENV NEXT_TELEMETRY_DISABLED=1 + COPY src ./src COPY server ./server COPY scripts ./scripts @@ -11,7 +13,7 @@ COPY package.json yarn.lock next.config.js next-env.d.ts zip-env.d.ts tsconfig.j RUN yarn install # create a mock config.toml to spoof next build! -RUN echo -e "[uploader]\nroute = '/u'\nembed_route = '/a'\nlength = 6\ndirectory = './uploads'" > config.toml +RUN echo -e "[uploader]\nroute = '/u'" > config.toml RUN yarn build diff --git a/Dockerignore b/Dockerignore deleted file mode 100644 index 1a2648e..0000000 --- a/Dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -prisma -node_modules -.next -uploads -.git diff --git a/package.json b/package.json index cd8fa60..8be2315 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,6 @@ }, "repository": { "type": "git", - "url": "https://github.com/diced/workflow-testing.git" + "url": "https://github.com/diced/zipline.git" } } diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 5c1db86..c56f665 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -50,11 +50,10 @@ model Image { } model InvisibleImage { - id Int @id @default(autoincrement()) - invis String @unique - + id Int @id @default(autoincrement()) + invis String @unique imageId Int - image Image @relation(fields: [imageId], references: [id]) + image Image @relation(fields: [imageId], references: [id]) } model Url { @@ -68,8 +67,7 @@ model Url { } model InvisibleUrl { - id Int - url Url @relation(fields: [id], references: [id]) - + id Int + url Url @relation(fields: [id], references: [id]) invis String @unique } diff --git a/server/index.js b/server/index.js index ad4e088..0ac4ff9 100644 --- a/server/index.js +++ b/server/index.js @@ -42,9 +42,7 @@ function shouldUseYarn() { Logger.get('database').info('some migrations are not applied, applying them now...'); await deployDb(config); Logger.get('database').info('finished applying migrations'); - } else { - Logger.get('database').info('migrations up to date'); - } + } else Logger.get('database').info('migrations up to date'); process.env.DATABASE_URL = config.core.database_url; await mkdir(config.uploader.directory, { recursive: true }); diff --git a/src/lib/hooks/useLogin.ts b/src/lib/hooks/useLogin.ts index dbaa904..1a78d75 100644 --- a/src/lib/hooks/useLogin.ts +++ b/src/lib/hooks/useLogin.ts @@ -14,21 +14,17 @@ export default function login() { async function load() { setLoading(true); + const res = await useFetch('/api/user'); - if (res.error) return router.push('/auth/login'); dispatch(updateUser(res)); - setUser(res); setLoading(false); } useEffect(() => { - if (!loading && user) { - return; - } - + if (!loading && user) return; load(); }, []); diff --git a/src/lib/logger.js b/src/lib/logger.js index 6925dce..6b1506d 100644 --- a/src/lib/logger.js +++ b/src/lib/logger.js @@ -31,10 +31,6 @@ class Logger { switch (level) { case 'INFO': return cyan('INFO '); - case 'DEBUG': - return yellow('DEBUG'); - case 'WARN': - return magenta('WARN '); case 'ERROR': return red('ERROR'); } diff --git a/src/pages/[...id].tsx b/src/pages/[...id].tsx index 21fb070..11f4b55 100644 --- a/src/pages/[...id].tsx +++ b/src/pages/[...id].tsx @@ -58,9 +58,7 @@ export default function EmbeddedImage({ image, title, username, color, normal, e export const getServerSideProps: GetServerSideProps = async (context) => { const id = context.params.id[1]; const route = context.params.id[0]; - if (route !== config.uploader.route.substring(1)) return { - notFound: true - }; + if (route !== config.uploader.route.substring(1)) return { notFound: true }; const image = await prisma.image.findFirst({ where: { diff --git a/src/pages/api/users.ts b/src/pages/api/users.ts index 825aa5e..619dc80 100644 --- a/src/pages/api/users.ts +++ b/src/pages/api/users.ts @@ -7,7 +7,7 @@ import { tryGetPreviewData } from 'next/dist/server/api-utils'; async function handler(req: NextApiReq, res: NextApiRes) { const user = await req.user(); if (!user) return res.forbid('not logged in'); - if (!user.administrator) return res.forbid('you arent an administrator'); + if (!user.administrator) return res.forbid('you aren\'t an administrator'); if (req.method === 'DELETE') { if (req.body.id === user.id) return res.forbid('you can\'t delete your own account'); @@ -28,7 +28,7 @@ async function handler(req: NextApiReq, res: NextApiRes) { delete deleteUser.password; return res.json(deleteUser); } else { - const all_users = await prisma.user.findMany({ + const users = await prisma.user.findMany({ select: { username: true, id: true, @@ -40,7 +40,7 @@ async function handler(req: NextApiReq, res: NextApiRes) { systemTheme: true } }); - return res.json(all_users); + return res.json(users); } } diff --git a/src/pages/dashboard/files.tsx b/src/pages/dashboard/files.tsx index 479a291..03b4c22 100644 --- a/src/pages/dashboard/files.tsx +++ b/src/pages/dashboard/files.tsx @@ -3,7 +3,7 @@ import useLogin from 'hooks/useLogin'; import Layout from 'components/Layout'; import Files from 'components/pages/Files'; -export default function ImagesPage() { +export default function FilesPage() { const { user, loading } = useLogin(); if (loading) return null; @@ -19,4 +19,4 @@ export default function ImagesPage() { ); } -ImagesPage.title = 'Zipline - Gallery'; \ No newline at end of file +FilesPage.title = 'Zipline - Gallery'; \ No newline at end of file diff --git a/src/pages/dashboard/users.tsx b/src/pages/dashboard/users.tsx index f525a35..90f4a5b 100644 --- a/src/pages/dashboard/users.tsx +++ b/src/pages/dashboard/users.tsx @@ -19,4 +19,4 @@ export default function UsersPage() { ); } -UsersPage.title = 'Zipline - User'; \ No newline at end of file +UsersPage.title = 'Zipline - Users'; \ No newline at end of file