docs: add missing import and type decl to sveltekit tutorial (#21634)

* docs: add missing import and type decl to sveltekit tutorial

* update +layout.server.ts in sveltekit code example

* update remaining

* chore: fix formatting

---------

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
This commit is contained in:
TuriiyaandCharis authored and GitHub committed 2024-03-07 21:17:48 +00:00
1 parent 4faafd0070
commit 74a1d5fec1
4 files changed
+16 -8

No files matched your search

@@ -1,5 +1,7 @@
// src/routes/+layout.server.ts
export const load = async ({ locals: { getSession } }) => {
import type { LayoutServerLoad } from './$types'
export const load: LayoutServerLoad = async ({ locals: { getSession } }) => {
return {
session: await getSession()
}
@@ -1,7 +1,8 @@
// src/routes/+page.server.ts
import { redirect } from '@sveltejs/kit'
import type { PageServerLoad } from './$types'
export const load = async ({ url, locals: { getSession } }) => {
export const load: PageServerLoad = async ({ url, locals: { getSession } }) => {
const session = await getSession()
// if the user is already logged in return them to the account page
@@ -1,6 +1,7 @@
import { fail, redirect } from '@sveltejs/kit'
import type { Actions, PageServerLoad } from './$types'
export const load = async ({ locals: { supabase, getSession } }) => {
export const load: PageServerLoad = async ({ locals: { supabase, getSession } }) => {
const session = await getSession()
if (!session) {
@@ -16,7 +17,7 @@ export const load = async ({ locals: { supabase, getSession } }) => {
return { profile }
}
export const actions = {
export const actions: Actions = {
update: async ({ request, locals: { supabase, getSession } }) => {
const formData = await request.formData()
const fullName = formData.get('fullName') as string