fix: many things

This commit is contained in:
diced 2021-09-17 20:39:20 -07:00
parent d956f4ed3d
commit dd6f192d4a
No known key found for this signature in database
GPG key ID: 85AB64C74535D76E
13 changed files with 25 additions and 38 deletions

4
.dockerignore Normal file
View file

@ -0,0 +1,4 @@
node_modules/
.next/
uploads/
.git/

2
.gitignore vendored
View file

@ -18,6 +18,7 @@
# misc
.DS_Store
*.pem
.idea
# debug
npm-debug.log*
@ -36,4 +37,3 @@ yarn-error.log*
# zipline
config.toml
uploads/
data.db*

View file

@ -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

View file

@ -1,5 +0,0 @@
prisma
node_modules
.next
uploads
.git

View file

@ -55,6 +55,6 @@
},
"repository": {
"type": "git",
"url": "https://github.com/diced/workflow-testing.git"
"url": "https://github.com/diced/zipline.git"
}
}

View file

@ -52,7 +52,6 @@ model Image {
model InvisibleImage {
id Int @id @default(autoincrement())
invis String @unique
imageId Int
image Image @relation(fields: [imageId], references: [id])
}
@ -70,6 +69,5 @@ model Url {
model InvisibleUrl {
id Int
url Url @relation(fields: [id], references: [id])
invis String @unique
}

View file

@ -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 });

View file

@ -14,21 +14,17 @@ export default function login() {
async function load() {
setLoading(true);
const res = await useFetch('/api/user');
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();
}, []);

View file

@ -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');
}

View file

@ -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: {

View file

@ -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);
}
}

View file

@ -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';

View file

@ -19,4 +19,4 @@ export default function UsersPage() {
);
}
UsersPage.title = 'Zipline - User';
UsersPage.title = 'Zipline - Users';