Update all dependencies

This takes part of the work being done in #96 that was reverted but still useful.

Note Tailwind and Fresh weren't upgraded because there's no security vulnerability in either, and I have found the new versions to be worse in performance. Thos will likely stay at those fixed versions going forward.
This commit is contained in:
Bruno Bernardino
2025-09-27 19:39:09 +01:00
parent ba2103afa9
commit 6734e9557b
45 changed files with 11027 additions and 127 deletions

View File

@@ -1,11 +1,6 @@
import { Head } from 'fresh/runtime.ts';
import { PageProps } from 'fresh/server.ts';
import { FreshContextState } from '/lib/types.ts';
interface Data {}
export default function Error404({ state }: PageProps<Data, FreshContextState>) {
export default function Error404() {
return (
<>
<Head>
@@ -13,20 +8,6 @@ export default function Error404({ state }: PageProps<Data, FreshContextState>)
</Head>
<main>
<section class='max-w-screen-md mx-auto flex flex-col items-center justify-center'>
{!state.user
? (
<>
<img
class='my-6'
src='/images/logo-white.svg'
width='250'
height='50'
alt='the bewCloud logo: a stylized logo'
/>
<h1>404 - Page not found</h1>
</>
)
: null}
<p class='my-4'>
The page you were looking for doesn't exist.
</p>

View File

@@ -1,6 +1,6 @@
import { Handler, RouteConfig } from 'fresh/server.ts';
import { join } from 'std/path/join.ts';
import { parse, stringify } from 'xml';
import { join } from '@std/path';
import { parse, stringify } from '@libs/xml';
import { FreshContextState } from '/lib/types.ts';
import { AppConfig } from '/lib/config.ts';
@@ -59,7 +59,7 @@ export const handler: Handler<Data, FreshContextState> = async (request, context
return new Response('Not Found', { status: 404 });
}
return new Response(fileResult.contents!, {
return new Response(fileResult.contents! as BodyInit, {
status: 200,
headers: {
'cache-control': 'no-cache, no-store, must-revalidate',

View File

@@ -1,5 +1,5 @@
import { Handlers, PageProps } from 'fresh/server.ts';
import { join } from 'std/path/join.ts';
import { join } from '@std/path';
import { Directory, DirectoryFile, FreshContextState } from '/lib/types.ts';
import {

View File

@@ -1,5 +1,5 @@
import { Handlers } from 'fresh/server.ts';
import { join } from 'std/path/join.ts';
import { join } from '@std/path';
import { FreshContextState } from '/lib/types.ts';
import { ensureFileSharePathIsValidAndSecurelyAccessible, FileModel, FileShareModel } from '/lib/models/files.ts';
@@ -70,7 +70,7 @@ export const handler: Handlers<Data, FreshContextState> = {
return new Response('Not Found', { status: 404 });
}
return new Response(fileResult.contents!, {
return new Response(fileResult.contents! as BodyInit, {
status: 200,
headers: {
'cache-control': 'no-cache, no-store, must-revalidate',

View File

@@ -37,7 +37,7 @@ export const handler: Handlers<Data, FreshContextState> = {
return new Response('Not Found', { status: 404 });
}
return new Response(fileResult.contents!, {
return new Response(fileResult.contents! as BodyInit, {
status: 200,
headers: {
'cache-control': 'no-cache, no-store, must-revalidate',

View File

@@ -1,5 +1,5 @@
import { Handlers } from 'fresh/server.ts';
import { resize } from 'https://deno.land/x/deno_image@0.0.4/mod.ts';
import sharp from 'sharp';
import { FreshContextState } from '/lib/types.ts';
import { FileModel } from '/lib/models/files.ts';
@@ -53,15 +53,36 @@ export const handler: Handlers<Data, FreshContextState> = {
return new Response('Bad Request', { status: 400 });
}
const resizedImageContents = await resize(fileResult.contents!, { width, height, aspectRatio: true });
try {
const image = sharp(fileResult.contents! as unknown as ArrayBuffer).resize({
width,
height,
fit: 'cover',
background: { r: 0, g: 0, b: 0, alpha: 0 },
}).png();
return new Response(resizedImageContents, {
status: 200,
headers: {
'cache-control': `max-age=${604_800}`, // Tell browsers to cache for 1 week (60 * 60 * 24 * 7 = 604_800)
'content-type': fileResult.contentType!,
'content-length': resizedImageContents.byteLength.toString(),
},
});
const resizedImageContents = await image.toBuffer();
return new Response(Uint8Array.from(resizedImageContents), {
status: 200,
headers: {
'cache-control': `max-age=${604_800}`, // Tell browsers to cache for 1 week (60 * 60 * 24 * 7 = 604_800)
'content-type': fileResult.contentType!,
'content-length': resizedImageContents.byteLength.toString(),
},
});
} catch (error) {
console.error(error);
// Serve original if we can't make a thumbnail
return new Response(fileResult.contents! as BodyInit, {
status: 200,
headers: {
'cache-control': `max-age=${604_800}`, // Tell browsers to cache for 1 week (60 * 60 * 24 * 7 = 604_800)
'content-type': fileResult.contentType!,
'content-length': fileResult.contents!.byteLength.toString(),
},
});
}
},
};