diff --git a/src/hooks.server.ts b/src/hooks.server.ts
index 17248ba..6c9611d 100644
--- a/src/hooks.server.ts
+++ b/src/hooks.server.ts
@@ -3,11 +3,11 @@ import type { Handle } from '@sveltejs/kit';
import { sveltekitSessionHandle } from 'svelte-kit-sessions';
export const handle: Handle = sveltekitSessionHandle({
- secret: SESH_SECRET
+ secret: SESH_SECRET
});
declare module 'svelte-kit-sessions' {
- interface SessionData {
- userId: string;
- }
+ interface SessionData {
+ userId: string;
+ }
}
diff --git a/src/lib/components/ui/alert-dialog/alert-dialog-action.svelte b/src/lib/components/ui/alert-dialog/alert-dialog-action.svelte
index 715a24f..469b785 100644
--- a/src/lib/components/ui/alert-dialog/alert-dialog-action.svelte
+++ b/src/lib/components/ui/alert-dialog/alert-dialog-action.svelte
@@ -1,7 +1,7 @@
{#if href}
-
+
{@render children?.()}
{:else}
diff --git a/src/lib/components/ui/button/index.ts b/src/lib/components/ui/button/index.ts
index fb585d7..5414d9d 100644
--- a/src/lib/components/ui/button/index.ts
+++ b/src/lib/components/ui/button/index.ts
@@ -2,8 +2,8 @@ import Root, {
type ButtonProps,
type ButtonSize,
type ButtonVariant,
- buttonVariants,
-} from "./button.svelte";
+ buttonVariants
+} from './button.svelte';
export {
Root,
@@ -13,5 +13,5 @@ export {
buttonVariants,
type ButtonProps,
type ButtonSize,
- type ButtonVariant,
+ type ButtonVariant
};
diff --git a/src/lib/components/ui/card/card-content.svelte b/src/lib/components/ui/card/card-content.svelte
index 1f52856..e517deb 100644
--- a/src/lib/components/ui/card/card-content.svelte
+++ b/src/lib/components/ui/card/card-content.svelte
@@ -1,7 +1,7 @@
-
+
{@render children?.()}
diff --git a/src/lib/components/ui/card/card-description.svelte b/src/lib/components/ui/card/card-description.svelte
index da02664..d6adb63 100644
--- a/src/lib/components/ui/card/card-description.svelte
+++ b/src/lib/components/ui/card/card-description.svelte
@@ -1,7 +1,7 @@
-
+
{@render children?.()}
diff --git a/src/lib/components/ui/card/card-footer.svelte b/src/lib/components/ui/card/card-footer.svelte
index 6894149..ab12955 100644
--- a/src/lib/components/ui/card/card-footer.svelte
+++ b/src/lib/components/ui/card/card-footer.svelte
@@ -1,7 +1,7 @@
-
+
{@render children?.()}
diff --git a/src/lib/components/ui/card/card-header.svelte b/src/lib/components/ui/card/card-header.svelte
index 1baa92c..e163e42 100644
--- a/src/lib/components/ui/card/card-header.svelte
+++ b/src/lib/components/ui/card/card-header.svelte
@@ -1,7 +1,7 @@
-
+
{@render children?.()}
diff --git a/src/lib/components/ui/card/card-title.svelte b/src/lib/components/ui/card/card-title.svelte
index a201620..bb6e4d3 100644
--- a/src/lib/components/ui/card/card-title.svelte
+++ b/src/lib/components/ui/card/card-title.svelte
@@ -1,7 +1,7 @@
@@ -13,8 +13,8 @@
- import type { WithElementRef, WithoutChildren } from "bits-ui";
- import type { HTMLAttributes } from "svelte/elements";
- import { cn } from "$lib/utils.js";
+ import type { WithElementRef, WithoutChildren } from 'bits-ui';
+ import type { HTMLAttributes } from 'svelte/elements';
+ import { cn } from '$lib/utils.js';
let {
ref = $bindable(null),
@@ -12,6 +12,6 @@
diff --git a/src/lib/config.ts b/src/lib/config.ts
index 9bc92a1..a9e5213 100644
--- a/src/lib/config.ts
+++ b/src/lib/config.ts
@@ -5,9 +5,9 @@ export const siteName = 'Stuff.Kasterpalu';
export const baseURL = 'https://stuff.kasterpalu.ee';
export const games: GamesObj = {
- '/pakubiiti': {
- name: 'Paku biiti',
- image: '',
- description: 'Sorteeri kolme suvalise muusika albumi pealkiri, artistid ja pilt.'
- }
+ '/pakubiiti': {
+ name: 'Paku biiti',
+ image: '',
+ description: 'Sorteeri kolme suvalise muusika albumi pealkiri, artistid ja pilt.'
+ }
};
diff --git a/src/lib/server/AlbumState.svelte.ts b/src/lib/server/AlbumState.svelte.ts
index c7ac8ba..5fb7c85 100644
--- a/src/lib/server/AlbumState.svelte.ts
+++ b/src/lib/server/AlbumState.svelte.ts
@@ -1,45 +1,45 @@
import type { AlbumSolveState } from '$lib/types';
class AlbumState {
- private albums: AlbumSolveState[] | undefined = undefined;
+ private albums: AlbumSolveState[] | undefined = undefined;
- setAlbums(data: AlbumSolveState[]) {
- if (!data) {
- return;
- }
+ setAlbums(data: AlbumSolveState[]) {
+ if (!data) {
+ return;
+ }
- this.albums = data;
- }
+ this.albums = data;
+ }
- checkSolve(data: AlbumSolveState[]) {
- if (!data || !this.albums) {
- return false;
- }
+ checkSolve(data: AlbumSolveState[]) {
+ if (!data || !this.albums) {
+ return false;
+ }
- for (const solve of data) {
- const search = this.albums.filter((album) => album.name === solve.name);
+ for (const solve of data) {
+ const search = this.albums.filter((album) => album.name === solve.name);
- if (!search) {
- return false;
- }
+ if (!search) {
+ return false;
+ }
- const matching = search.at(0);
+ const matching = search.at(0);
- if (!matching) {
- return false;
- }
+ if (!matching) {
+ return false;
+ }
- if (matching.image !== solve.image) {
- return false;
- }
+ if (matching.image !== solve.image) {
+ return false;
+ }
- if (matching.artists !== solve.artists) {
- return false;
- }
- }
+ if (matching.artists !== solve.artists) {
+ return false;
+ }
+ }
- return true;
- }
+ return true;
+ }
}
export const albumState = new AlbumState();
diff --git a/src/lib/server/Spotify.svelte.ts b/src/lib/server/Spotify.svelte.ts
index 84445e7..4c79c7c 100644
--- a/src/lib/server/Spotify.svelte.ts
+++ b/src/lib/server/Spotify.svelte.ts
@@ -3,59 +3,59 @@ import { CLIENT_ID, CLIENT_SECRET } from '$env/static/private';
import { getRandomSearch } from '$lib/utils';
class SpotifyAPI {
- private api = new SpotifyWebApi({
- clientId: CLIENT_ID,
- clientSecret: CLIENT_SECRET
- });
- private exiresAt: Date = $state(new Date());
+ private api = new SpotifyWebApi({
+ clientId: CLIENT_ID,
+ clientSecret: CLIENT_SECRET
+ });
+ private exiresAt: Date = $state(new Date());
- async refreshAccessToken() {
- // If current token is valid for at least 100ms more
- if (this.exiresAt.getTime() - new Date().getTime() > 10) {
- return true;
- }
+ async refreshAccessToken() {
+ // If current token is valid for at least 100ms more
+ if (this.exiresAt.getTime() - new Date().getTime() > 10) {
+ return true;
+ }
- return await this.api.clientCredentialsGrant().then(
- (data) => {
- if (!data.body['expires_in'] || !data.body['access_token']) {
- return false;
- }
+ return await this.api.clientCredentialsGrant().then(
+ (data) => {
+ if (!data.body['expires_in'] || !data.body['access_token']) {
+ return false;
+ }
- const new_date = new Date();
- new_date.setSeconds(new_date.getSeconds() + Number(data.body['expires_in']));
+ const new_date = new Date();
+ new_date.setSeconds(new_date.getSeconds() + Number(data.body['expires_in']));
- this.exiresAt = new_date;
- this.api.setAccessToken(data.body['access_token']);
+ this.exiresAt = new_date;
+ this.api.setAccessToken(data.body['access_token']);
- return true;
- },
- function (err) {
- console.log('Something went wrong when retrieving an access token', err);
- return false;
- }
- );
- }
+ return true;
+ },
+ function (err) {
+ console.log('Something went wrong when retrieving an access token', err);
+ return false;
+ }
+ );
+ }
- async getRandomAlbum() {
- if (!(await this.refreshAccessToken())) {
- return undefined;
- }
+ async getRandomAlbum() {
+ if (!(await this.refreshAccessToken())) {
+ return undefined;
+ }
- const randomSearch = getRandomSearch();
- const randomOffset = Math.floor(Math.random() * 1000);
+ const randomSearch = getRandomSearch();
+ const randomOffset = Math.floor(Math.random() * 1000);
- return await this.api.search(randomSearch, ['album'], { limit: 1, offset: randomOffset }).then(
- function (data) {
- if (data.body.albums?.items?.at(0)) {
- return data.body.albums.items.at(0);
- }
- },
- (err) => {
- console.log(err);
- return undefined;
- }
- );
- }
+ return await this.api.search(randomSearch, ['album'], { limit: 1, offset: randomOffset }).then(
+ function (data) {
+ if (data.body.albums?.items?.at(0)) {
+ return data.body.albums.items.at(0);
+ }
+ },
+ (err) => {
+ console.log(err);
+ return undefined;
+ }
+ );
+ }
}
export const spotifyAPI = new SpotifyAPI();
diff --git a/src/lib/types.ts b/src/lib/types.ts
index 8cf0f73..51aa872 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -1,31 +1,31 @@
export type AlbumData = {
- names: AlbumDataField[];
- artists: AlbumDataField[];
- images: AlbumDataField[];
+ names: AlbumDataField[];
+ artists: AlbumDataField[];
+ images: AlbumDataField[];
};
export type AlbumDataField = {
- id: string;
- value: string;
+ id: string;
+ value: string;
};
export type AlbumSolveState = {
- name: string;
- artists: string;
- image: string;
+ name: string;
+ artists: string;
+ image: string;
};
export type Player = {
- id: string;
- stage: number;
- highscore: number;
- playing: boolean;
+ id: string;
+ stage: number;
+ highscore: number;
+ playing: boolean;
};
export type Game = {
- name: string;
- image: string;
- description: string;
+ name: string;
+ image: string;
+ description: string;
};
export type GamesObj = Record;
diff --git a/src/routes/(games)/+layout.server.ts b/src/routes/(games)/+layout.server.ts
index 57b1185..4f7e758 100644
--- a/src/routes/(games)/+layout.server.ts
+++ b/src/routes/(games)/+layout.server.ts
@@ -2,19 +2,19 @@ import type { LayoutServerData } from './$types';
import { games } from '$lib/config';
export const load: LayoutServerData = async ({ url }) => {
- if (!url?.pathname) {
- return;
- }
+ if (!url?.pathname) {
+ return;
+ }
- const game = games[url.pathname];
+ const game = games[url.pathname];
- if (!game) {
- return;
- }
+ if (!game) {
+ return;
+ }
- return {
- name: game.name,
- description: game.description,
- image: game.image
- };
+ return {
+ name: game.name,
+ description: game.description,
+ image: game.image
+ };
};
diff --git a/src/routes/api/pakubiiti/getAlbums/[count]/+server.ts b/src/routes/api/pakubiiti/getAlbums/[count]/+server.ts
index 23aadfb..4194233 100644
--- a/src/routes/api/pakubiiti/getAlbums/[count]/+server.ts
+++ b/src/routes/api/pakubiiti/getAlbums/[count]/+server.ts
@@ -4,27 +4,27 @@ import type { AlbumSolveState } from '$lib/types';
import { json } from '@sveltejs/kit';
export async function GET({ params }) {
- const count = params.count || 1;
+ const count = params.count || 1;
- const albums: AlbumSolveState[] = [];
+ const albums: AlbumSolveState[] = [];
- for (let i = 0; i < count; i++) {
- const album = await spotifyAPI.getRandomAlbum();
- if (album) {
- const image = album.images.at(0);
- if (!image?.url) {
- return;
- }
+ for (let i = 0; i < count; i++) {
+ const album = await spotifyAPI.getRandomAlbum();
+ if (album) {
+ const image = album.images.at(0);
+ if (!image?.url) {
+ return;
+ }
- albums.push({
- name: album.name,
- artists: album.artists.map((artist) => artist.name).join(', '),
- image: image.url
- });
- }
- }
+ albums.push({
+ name: album.name,
+ artists: album.artists.map((artist) => artist.name).join(', '),
+ image: image.url
+ });
+ }
+ }
- albumState.setAlbums(albums);
+ albumState.setAlbums(albums);
- return json({ albums: albums });
+ return json({ albums: albums });
}
diff --git a/static/site.webmanifest b/static/site.webmanifest
index 5dbacf6..2afa19f 100644
--- a/static/site.webmanifest
+++ b/static/site.webmanifest
@@ -1,21 +1,21 @@
{
- "name": "Kasterpalu",
- "short_name": "Kasterpalu",
- "icons": [
- {
- "src": "/web-app-manifest-192x192.png",
- "sizes": "192x192",
- "type": "image/png",
- "purpose": "maskable"
- },
- {
- "src": "/web-app-manifest-512x512.png",
- "sizes": "512x512",
- "type": "image/png",
- "purpose": "maskable"
- }
- ],
- "theme_color": "#ffffff",
- "background_color": "#ffffff",
- "display": "standalone"
-}
\ No newline at end of file
+ "name": "Kasterpalu",
+ "short_name": "Kasterpalu",
+ "icons": [
+ {
+ "src": "/web-app-manifest-192x192.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "maskable"
+ },
+ {
+ "src": "/web-app-manifest-512x512.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "maskable"
+ }
+ ],
+ "theme_color": "#ffffff",
+ "background_color": "#ffffff",
+ "display": "standalone"
+}