mirror of
https://github.com/diced/zipline.git
synced 2025-12-13 00:00:14 -08:00
fix: many things
This commit is contained in:
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
.next/
|
||||
uploads/
|
||||
.git/
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -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*
|
||||
uploads/
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
prisma
|
||||
node_modules
|
||||
.next
|
||||
uploads
|
||||
.git
|
||||
@@ -55,6 +55,6 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/diced/workflow-testing.git"
|
||||
"url": "https://github.com/diced/zipline.git"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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();
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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';
|
||||
FilesPage.title = 'Zipline - Gallery';
|
||||
@@ -19,4 +19,4 @@ export default function UsersPage() {
|
||||
);
|
||||
}
|
||||
|
||||
UsersPage.title = 'Zipline - User';
|
||||
UsersPage.title = 'Zipline - Users';
|
||||
Reference in New Issue
Block a user