Skip to content

disable +page.server.js #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified frontend/src/lib/wailsjs/go/main/App.d.ts
100644 → 100755
Empty file.
Empty file modified frontend/src/lib/wailsjs/go/main/App.js
100644 → 100755
Empty file.
112 changes: 56 additions & 56 deletions frontend/src/routes/sverdle/+page.server.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
import { fail } from '@sveltejs/kit';
import { Game } from './game';
// import { fail } from '@sveltejs/kit';
// import { Game } from './game';

/** @satisfies {import('./$types').PageServerLoad} */
export const load = ({ cookies }) => {
const game = new Game(cookies.get('sverdle'));
// /** @satisfies {import('./$types').PageServerLoad} */
// export const load = ({ cookies }) => {
// const game = new Game(cookies.get('sverdle'));

return {
/**
* The player's guessed words so far
*/
guesses: game.guesses,
// return {
// /**
// * The player's guessed words so far
// */
// guesses: game.guesses,

/**
* An array of strings like '__x_c' corresponding to the guesses, where 'x' means
* an exact match, and 'c' means a close match (right letter, wrong place)
*/
answers: game.answers,
// /**
// * An array of strings like '__x_c' corresponding to the guesses, where 'x' means
// * an exact match, and 'c' means a close match (right letter, wrong place)
// */
// answers: game.answers,

/**
* The correct answer, revealed if the game is over
*/
answer: game.answers.length >= 6 ? game.answer : null
};
};
// /**
// * The correct answer, revealed if the game is over
// */
// answer: game.answers.length >= 6 ? game.answer : null
// };
// };

/** @satisfies {import('./$types').Actions} */
export const actions = {
/**
* Modify game state in reaction to a keypress. If client-side JavaScript
* is available, this will happen in the browser instead of here
*/
update: async ({ request, cookies }) => {
const game = new Game(cookies.get('sverdle'));
// /** @satisfies {import('./$types').Actions} */
// export const actions = {
// /**
// * Modify game state in reaction to a keypress. If client-side JavaScript
// * is available, this will happen in the browser instead of here
// */
// update: async ({ request, cookies }) => {
// const game = new Game(cookies.get('sverdle'));

const data = await request.formData();
const key = data.get('key');
// const data = await request.formData();
// const key = data.get('key');

const i = game.answers.length;
// const i = game.answers.length;

if (key === 'backspace') {
game.guesses[i] = game.guesses[i].slice(0, -1);
} else {
game.guesses[i] += key;
}
// if (key === 'backspace') {
// game.guesses[i] = game.guesses[i].slice(0, -1);
// } else {
// game.guesses[i] += key;
// }

cookies.set('sverdle', game.toString(), { path: '/' });
},
// cookies.set('sverdle', game.toString(), { path: '/' });
// },

/**
* Modify game state in reaction to a guessed word. This logic always runs on
* the server, so that people can't cheat by peeking at the JavaScript
*/
enter: async ({ request, cookies }) => {
const game = new Game(cookies.get('sverdle'));
// /**
// * Modify game state in reaction to a guessed word. This logic always runs on
// * the server, so that people can't cheat by peeking at the JavaScript
// */
// enter: async ({ request, cookies }) => {
// const game = new Game(cookies.get('sverdle'));

const data = await request.formData();
const guess = /** @type {string[]} */ (data.getAll('guess'));
// const data = await request.formData();
// const guess = /** @type {string[]} */ (data.getAll('guess'));

if (!game.enter(guess)) {
return fail(400, { badGuess: true });
}
// if (!game.enter(guess)) {
// return fail(400, { badGuess: true });
// }

cookies.set('sverdle', game.toString(), { path: '/' });
},
// cookies.set('sverdle', game.toString(), { path: '/' });
// },

restart: async ({ cookies }) => {
cookies.delete('sverdle', { path: '/' });
}
};
// restart: async ({ cookies }) => {
// cookies.delete('sverdle', { path: '/' });
// }
// };
2 changes: 0 additions & 2 deletions frontend/src/routes/sverdle/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import { reduced_motion } from './reduced-motion';

goto('/<some>/<page>')

/** @type {import('./$types').PageData} */
export let data;

Expand Down