-
About this app
-
-
- This is a SvelteKit app. You can make your own by typing the
- following into your command line and following the prompts:
-
-
-
-
npm init svelte@next
-
-
- The page you're looking at is purely static HTML, with no client-side interactivity needed.
- Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening
- the devtools network panel and reloading.
-
-
-
- The TODOs page illustrates SvelteKit's data loading and form handling. Try using
- it with JavaScript disabled!
-
-
-
-
diff --git a/src/routes/todos/_api.js b/src/routes/todos/_api.js
deleted file mode 100644
index 5682be8..0000000
--- a/src/routes/todos/_api.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- This module is used by the /todos endpoint to
- make calls to api.svelte.dev, which stores todos
- for each user. The leading underscore indicates that this is
- a private module, _not_ an endpoint — visiting /todos/_api
- will net you a 404 response.
-
- (The data on the todo app will expire periodically; no
- guarantees are made. Don't use it to organise your life.)
-*/
-
-const base = 'https://api.svelte.dev';
-
-export function api(method, resource, data) {
- return fetch(`${base}/${resource}`, {
- method,
- headers: {
- 'content-type': 'application/json'
- },
- body: data && JSON.stringify(data)
- });
-}
diff --git a/src/routes/todos/index.js b/src/routes/todos/index.js
deleted file mode 100644
index 92edf96..0000000
--- a/src/routes/todos/index.js
+++ /dev/null
@@ -1,66 +0,0 @@
-import { api } from './_api';
-
-export const get = async ({ locals }) => {
- // locals.userid comes from src/hooks.js
- const response = await api('get', `todos/${locals.userid}`);
-
- if (response.status === 404) {
- // user hasn't created a todo list.
- // start with an empty array
- return {
- body: {
- todos: []
- }
- };
- }
-
- if (response.status === 200) {
- return {
- body: {
- todos: await response.json()
- }
- };
- }
-
- return {
- status: response.status
- };
-};
-
-export const post = async ({ request, locals }) => {
- const form = await request.formData();
-
- await api('post', `todos/${locals.userid}`, {
- text: form.get('text')
- });
-
- return {};
-};
-
-// If the user has JavaScript disabled, the URL will change to
-// include the method override unless we redirect back to /todos
-const redirect = {
- status: 303,
- headers: {
- location: '/todos'
- }
-};
-
-export const patch = async ({ request, locals }) => {
- const form = await request.formData();
-
- await api('patch', `todos/${locals.userid}/${form.get('uid')}`, {
- text: form.has('text') ? form.get('text') : undefined,
- done: form.has('done') ? !!form.get('done') : undefined
- });
-
- return redirect;
-};
-
-export const del = async ({ request, locals }) => {
- const form = await request.formData();
-
- await api('delete', `todos/${locals.userid}/${form.get('uid')}`);
-
- return redirect;
-};
diff --git a/src/routes/todos/index.svelte b/src/routes/todos/index.svelte
deleted file mode 100644
index d4d81ed..0000000
--- a/src/routes/todos/index.svelte
+++ /dev/null
@@ -1,178 +0,0 @@
-
-
-
-
Todos
-
-
-
- {#each todos as todo (todo.uid)}
-
-
-
-
-
-
-
- {/each}
-
-
-