feat: run server functions on edge

This commit is contained in:
2023-02-10 18:50:02 +01:00
parent e1f739b095
commit ed16fb9765
17 changed files with 64 additions and 0 deletions

View File

@@ -3,6 +3,10 @@ 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 config = {
runtime: 'edge'
}
export const load = (async () => { export const load = (async () => {
try { try {
// Get content from API // Get content from API

View File

@@ -4,6 +4,10 @@ import { fetchAPI } from '$utils/api'
import { getRandomItem } from 'utils/array' import { getRandomItem } from 'utils/array'
import { fetchSwell } from '$utils/functions/shopServer' import { fetchSwell } from '$utils/functions/shopServer'
export const config = {
runtime: 'edge'
}
export const load = (async ({ setHeaders }) => { export const load = (async ({ setHeaders }) => {
try { try {
// Get content from API // Get content from API

View File

@@ -3,6 +3,10 @@ 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 config = {
runtime: 'edge'
}
export const load = (async ({ params, setHeaders }) => { export const load = (async ({ params, setHeaders }) => {
try { try {
// Get content from API // Get content from API

View File

@@ -3,6 +3,10 @@ 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 config = {
runtime: 'edge'
}
export const load = (async ({ params, setHeaders }) => { export const load = (async ({ params, setHeaders }) => {
try { try {
const { location: slug } = params const { location: slug } = params

View File

@@ -2,6 +2,10 @@ 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 config = {
runtime: 'edge'
}
export const load = (async ({ params, setHeaders }) => { export const load = (async ({ params, setHeaders }) => {
try { try {
// Get the first photo ID // Get the first photo ID

View File

@@ -3,6 +3,10 @@ import type { PageServerLoad } from './$types'
import { fetchAPI } from '$utils/api' import { fetchAPI } from '$utils/api'
import { getRandomItems } from 'utils/array' import { getRandomItems } from 'utils/array'
export const config = {
runtime: 'edge'
}
export const load = (async ({ setHeaders }) => { export const load = (async ({ setHeaders }) => {
try { try {
// Get data and total of published photos // Get data and total of published photos

View File

@@ -2,6 +2,10 @@ 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 config = {
runtime: 'edge'
}
export const POST = (async ({ request, setHeaders }) => { export const POST = (async ({ request, setHeaders }) => {
try { try {
const body = await request.text() const body = await request.text()

View File

@@ -2,6 +2,10 @@ 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 config = {
runtime: 'edge'
}
export const load = (async ({ setHeaders }) => { export const load = (async ({ setHeaders }) => {
try { try {
const res = await fetchAPI(`query { const res = await fetchAPI(`query {

View File

@@ -3,6 +3,10 @@ import type { RequestHandler } from './$types'
import { fetchSwell } from '$utils/functions/shopServer' import { fetchSwell } from '$utils/functions/shopServer'
import { fetchAPI, getAssetUrlKey } from '$utils/api' import { fetchAPI, getAssetUrlKey } from '$utils/api'
export const config = {
runtime: 'edge'
}
const gCategories = [ const gCategories = [
{ {
id: '61851d83cd16416c78a8e5ef', id: '61851d83cd16416c78a8e5ef',

View File

@@ -0,0 +1,3 @@
export const config = {
runtime: 'edge'
}

View File

@@ -3,6 +3,10 @@ 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 config = {
runtime: 'edge'
}
export const load = (async ({ url, setHeaders }) => { export const load = (async ({ url, setHeaders }) => {
try { try {
// Query parameters // Query parameters

View File

@@ -2,6 +2,10 @@ 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 config = {
runtime: 'edge'
}
export const load = (async ({ setHeaders }) => { export const load = (async ({ setHeaders }) => {
try { try {
const res = await fetchAPI(`query { const res = await fetchAPI(`query {

View File

@@ -2,6 +2,10 @@ 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 config = {
runtime: 'edge'
}
export const load = (async ({ setHeaders }) => { export const load = (async ({ setHeaders }) => {
try { try {
const res = await fetchAPI(`query { const res = await fetchAPI(`query {

View File

@@ -3,6 +3,9 @@ import type { LayoutServerLoad } from './$types'
import { fetchAPI } from '$utils/api' import { fetchAPI } from '$utils/api'
import { PUBLIC_PREVIEW_COUNT } from '$env/static/public' import { PUBLIC_PREVIEW_COUNT } from '$env/static/public'
export const config = {
runtime: 'edge'
}
export const load = (async () => { export const load = (async () => {
try { try {

View File

@@ -3,6 +3,9 @@ import type { PageServerLoad } from './$types'
import { fetchAPI } from '$utils/api' import { fetchAPI } from '$utils/api'
import { getRandomItems } from 'utils/array' import { getRandomItems } from 'utils/array'
export const config = {
runtime: 'edge'
}
export const load = (async ({ setHeaders }) => { export const load = (async ({ setHeaders }) => {
try { try {

View File

@@ -1,6 +1,10 @@
import { NEWSLETTER_API_TOKEN, NEWSLETTER_LIST_ID } from '$env/static/private' import { NEWSLETTER_API_TOKEN, NEWSLETTER_LIST_ID } from '$env/static/private'
import type { RequestHandler } from './$types' import type { RequestHandler } from './$types'
export const config = {
runtime: 'edge'
}
export const POST = (async ({ request, fetch }) => { export const POST = (async ({ request, fetch }) => {
const data: { email: string } = await request.json() const data: { email: string } = await request.json()
const { email } = data const { email } = data

View File

@@ -2,6 +2,9 @@ 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 config = {
runtime: 'edge'
}
export const GET = (async ({ url, setHeaders }) => { export const GET = (async ({ url, setHeaders }) => {
try { try {