Move to TypeScript
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import { getMetadata } from '$lib/util/album';
|
||||
import { getAlbumUri, getZipName } from '$lib/util/links';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
/** @type {import('./$types').PageLoad} */
|
||||
export async function load({ params }) {
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
const album = await getMetadata(getZipName(params));
|
||||
const base = getAlbumUri(params);
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
<script>
|
||||
<script type="ts">
|
||||
import { strf } from '$lib/data/language.js';
|
||||
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import Gallery from '$lib/components/Gallery.svelte';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
|
||||
//const uriBase = `/s/apitest.php?slug=${data.slug}` + (data.timestamp ? `×tamp=${data.timestamp}` : '');
|
||||
export let data: PageData;
|
||||
</script>
|
||||
|
||||
<Header title={$strf(data.album.title)}/>
|
||||
|
||||
@ -2,9 +2,9 @@ import { getMetadata } from '$lib/util/album';
|
||||
import { getZipName } from '$lib/util/links';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import fs from 'node:fs/promises';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function GET({ params, url }) {
|
||||
export const GET: RequestHandler = async ({ params, url }) => {
|
||||
try {
|
||||
const zipName = getZipName(params);
|
||||
const album = await getMetadata(zipName);
|
||||
@ -1,8 +1,8 @@
|
||||
import { getMetadata } from '$lib/util/album';
|
||||
import { getFileName, getFilePath, getZipName } from '$lib/util/links.js';
|
||||
import { getFileName, getFilePath, getZipName } from '$lib/util/links';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
/** @type {import('./$types').PageLoad} */
|
||||
export async function load({ params }) {
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
const album = await getMetadata(getZipName(params));
|
||||
const filePath = getFilePath(params.item);
|
||||
const item = album.items.find(item => item.item === filePath);
|
||||
@ -1,8 +1,8 @@
|
||||
<script>
|
||||
<script type="ts">
|
||||
import { strf } from '$lib/data/language';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
export let data: PageData;
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { getMetadataAndFile } from '$lib/util/album';
|
||||
import { getZipName, getFileName, getFilePath } from '$lib/util/links';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function GET({ params }) {
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
try {
|
||||
const {album, content} = await getMetadataAndFile(getZipName(params), getFilePath(params.item));
|
||||
const allowDownload = album.allowDownload === false ? false : true;
|
||||
@ -2,9 +2,10 @@ import { getFile } from '$lib/util/album';
|
||||
import { getFileName, getFilePath, getZipName } from '$lib/util/links';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import sharp from 'sharp';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function GET({ params }) {
|
||||
/** @type {RequestHandler} */
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
let thumbnail = null;
|
||||
console.log(`Getting thumbnail for ${params}`);
|
||||
let width = 400;
|
||||
@ -24,7 +25,7 @@ export async function GET({ params }) {
|
||||
}
|
||||
}
|
||||
thumbnail = thumbnail || await sharp(content).resize(width).webp({ quality: 90 }).toBuffer();
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
console.error(`${/** @type {Error} */(err).stack}`.replaceAll('/home/sveltekit', '.'));
|
||||
throw error(500, 'Error getting thumbnail');
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
import StreamZip from 'node-stream-zip';
|
||||
import sharp from 'sharp';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function GET({ params }) {
|
||||
/** @type {RequestHandler} */
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
|
||||
let entryData = null;
|
||||
try {
|
||||
Reference in New Issue
Block a user