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