[chore] Use satisfies syntax for server routes types
This commit is contained in:
@@ -3,7 +3,7 @@ import type { LayoutServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
import { fetchSwell } from '$utils/functions/shopServer'
|
||||
|
||||
export const load: LayoutServerLoad = async () => {
|
||||
export const load = (async () => {
|
||||
try {
|
||||
// Get content from API
|
||||
const res = await fetchAPI(`query {
|
||||
@@ -75,4 +75,4 @@ export const load: LayoutServerLoad = async () => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies LayoutServerLoad
|
||||
|
||||
@@ -4,7 +4,7 @@ import { fetchAPI } from '$utils/api'
|
||||
import { getRandomItem } from '$utils/functions'
|
||||
import { fetchSwell } from '$utils/functions/shopServer'
|
||||
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
export const load = (async ({ setHeaders }) => {
|
||||
try {
|
||||
// Get content from API
|
||||
const data = await fetchAPI(`query {
|
||||
@@ -53,4 +53,4 @@ export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
import { fetchSwell } from '$utils/functions/shopServer'
|
||||
|
||||
export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
||||
export const load = (async ({ params, setHeaders }) => {
|
||||
try {
|
||||
// Get content from API
|
||||
const data = await fetchAPI(`query {
|
||||
@@ -50,4 +50,4 @@ export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(404)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -3,11 +3,7 @@ import type { PageServerLoad } from './$types'
|
||||
import { PUBLIC_LIST_AMOUNT } from '$env/static/public'
|
||||
import { fetchAPI, photoFields } from '$utils/api'
|
||||
|
||||
|
||||
/**
|
||||
* Page Data
|
||||
*/
|
||||
export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
||||
export const load = (async ({ params, setHeaders }) => {
|
||||
try {
|
||||
const { location: slug } = params
|
||||
|
||||
@@ -91,4 +87,4 @@ export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -2,7 +2,7 @@ import { error } from '@sveltejs/kit'
|
||||
import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
||||
export const load = (async ({ params, setHeaders }) => {
|
||||
try {
|
||||
// Get the first photo ID
|
||||
const firstPhoto = await fetchAPI(`query {
|
||||
@@ -88,4 +88,4 @@ export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
import { getRandomItems } from '$utils/functions'
|
||||
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
export const load = (async ({ setHeaders }) => {
|
||||
try {
|
||||
// Get data and total of published photos
|
||||
const res = await fetchAPI(`query {
|
||||
@@ -101,4 +101,4 @@ export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -2,8 +2,7 @@ import { error } from '@sveltejs/kit'
|
||||
import type { RequestHandler } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
|
||||
export const POST: RequestHandler = async ({ request, setHeaders }) => {
|
||||
export const POST = (async ({ request, setHeaders }) => {
|
||||
try {
|
||||
const body = await request.text()
|
||||
|
||||
@@ -22,4 +21,4 @@ export const POST: RequestHandler = async ({ request, setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies RequestHandler
|
||||
|
||||
@@ -2,7 +2,7 @@ import { error } from '@sveltejs/kit'
|
||||
import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
export const load = (async ({ setHeaders }) => {
|
||||
try {
|
||||
const res = await fetchAPI(`query {
|
||||
credits {
|
||||
@@ -40,4 +40,4 @@ export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -11,7 +11,7 @@ const gCategories = [
|
||||
}
|
||||
]
|
||||
|
||||
export const GET: RequestHandler = async ({ url, setHeaders }) => {
|
||||
export const GET = (async ({ url, setHeaders }) => {
|
||||
try {
|
||||
const products = []
|
||||
|
||||
@@ -65,8 +65,10 @@ export const GET: RequestHandler = async ({ url, setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies RequestHandler
|
||||
|
||||
|
||||
// Render sitemap
|
||||
const render = (origin: string, products: any[]) => {
|
||||
return `<?xml version="1.0"?>
|
||||
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
|
||||
|
||||
@@ -3,11 +3,7 @@ import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
import { PUBLIC_FILTERS_DEFAULT_COUNTRY, PUBLIC_FILTERS_DEFAULT_SORT, PUBLIC_GRID_AMOUNT } from '$env/static/public'
|
||||
|
||||
|
||||
/**
|
||||
* Page Data
|
||||
*/
|
||||
export const load: PageServerLoad = async ({ url, setHeaders }) => {
|
||||
export const load = (async ({ url, setHeaders }) => {
|
||||
try {
|
||||
// Query parameters
|
||||
const queryCountry = url.searchParams.get('country') || PUBLIC_FILTERS_DEFAULT_COUNTRY
|
||||
@@ -88,4 +84,4 @@ export const load: PageServerLoad = async ({ url, setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -2,11 +2,7 @@ import { error } from '@sveltejs/kit'
|
||||
import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
|
||||
/**
|
||||
* Page Data
|
||||
*/
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
export const load = (async ({ setHeaders }) => {
|
||||
try {
|
||||
const res = await fetchAPI(`query {
|
||||
settings {
|
||||
@@ -39,4 +35,4 @@ export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -2,7 +2,7 @@ import { error } from '@sveltejs/kit'
|
||||
import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
export const load = (async ({ setHeaders }) => {
|
||||
try {
|
||||
const res = await fetchAPI(`query {
|
||||
legal {
|
||||
@@ -23,4 +23,4 @@ export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -4,7 +4,7 @@ import { fetchAPI } from '$utils/api'
|
||||
import { PUBLIC_PREVIEW_COUNT } from '$env/static/public'
|
||||
|
||||
|
||||
export const load: LayoutServerLoad = async () => {
|
||||
export const load = (async () => {
|
||||
try {
|
||||
const res = await fetchAPI(`query {
|
||||
locations: location (filter: { status: { _eq: "published" }}) {
|
||||
@@ -102,4 +102,4 @@ export const load: LayoutServerLoad = async () => {
|
||||
} catch (err) {
|
||||
throw error(500, err || 'Failed to fetch data')
|
||||
}
|
||||
}
|
||||
}) satisfies LayoutServerLoad
|
||||
|
||||
@@ -4,10 +4,7 @@ import { fetchAPI } from '$utils/api'
|
||||
import { getRandomItems } from '$utils/functions'
|
||||
|
||||
|
||||
/**
|
||||
* Page Data
|
||||
*/
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
export const load = (async ({ setHeaders }) => {
|
||||
try {
|
||||
// Get total of published photos
|
||||
const totalRes = await fetchAPI(`query {
|
||||
@@ -56,4 +53,4 @@ export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies PageServerLoad
|
||||
|
||||
@@ -37,4 +37,4 @@ export const POST = (async ({ request, fetch }) => {
|
||||
}), {
|
||||
status: 200
|
||||
})
|
||||
}) satisfies RequestHandler
|
||||
}) satisfies RequestHandler
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { RequestHandler } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
|
||||
export const GET: RequestHandler = async ({ url, setHeaders }) => {
|
||||
export const GET = (async ({ url, setHeaders }) => {
|
||||
try {
|
||||
const locations = []
|
||||
const products = []
|
||||
@@ -72,7 +72,8 @@ export const GET: RequestHandler = async ({ url, setHeaders }) => {
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
}) satisfies RequestHandler
|
||||
|
||||
|
||||
const render = (origin: string, pages: any[]) => {
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>
|
||||
@@ -90,4 +91,4 @@ const render = (origin: string, pages: any[]) => {
|
||||
<changefreq>${frequency}</changefreq>
|
||||
</url>`).join('')}
|
||||
</urlset>`
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user