Rename methods to match HTTP requests

This commit is contained in:
2022-07-15 20:44:06 +02:00
parent 7fa05ab6d3
commit 56118d611d
10 changed files with 12 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit' import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit'
import { fetchAPI } from '$utils/api' import { fetchAPI } from '$utils/api'
export async function get({ params }: RequestEvent): Promise<RequestHandlerOutput> { export async function GET ({ params }: RequestEvent): Promise<RequestHandlerOutput> {
try { try {
// Get the first photo ID // Get the first photo ID
const firstPhoto = await fetchAPI(` const firstPhoto = await fetchAPI(`

View File

@@ -14,7 +14,7 @@ export const photoFields = `
date_created date_created
` `
export async function get({ params }: RequestEvent): Promise<RequestHandlerOutput> { export async function GET ({ params }: RequestEvent): Promise<RequestHandlerOutput> {
try { try {
const { location: slug } = params const { location: slug } = params

View File

@@ -2,7 +2,7 @@ import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit'
// Block GET requests // Block GET requests
export async function get({}: RequestEvent): Promise<RequestHandlerOutput> { export async function GET ({}: RequestEvent): Promise<RequestHandlerOutput> {
return { return {
status: 403, status: 403,
body: 'nope!' body: 'nope!'
@@ -13,7 +13,7 @@ export async function get({}: RequestEvent): Promise<RequestHandlerOutput> {
/** /**
* POST request * POST request
*/ */
export async function post ({ request }: RequestEvent): Promise<RequestHandlerOutput> { export async function POST ({ request }: RequestEvent): Promise<RequestHandlerOutput> {
const body = await request.text() const body = await request.text()
if (body) { if (body) {

View File

@@ -11,7 +11,7 @@ import {
// Block GET requests // Block GET requests
export async function get({}: RequestEvent): Promise<RequestHandlerOutput> { export async function GET ({}: RequestEvent): Promise<RequestHandlerOutput> {
return { return {
status: 403, status: 403,
body: 'nope!' body: 'nope!'
@@ -22,7 +22,7 @@ export async function get({}: RequestEvent): Promise<RequestHandlerOutput> {
/** /**
* POST request * POST request
*/ */
export async function post ({ request }: RequestEvent): Promise<RequestHandlerOutput> { export async function POST ({ request }: RequestEvent): Promise<RequestHandlerOutput> {
try { try {
const body = await request.json() const body = await request.json()
const { action, cartId, productId } = body const { action, cartId, productId } = body

View File

@@ -1,7 +1,7 @@
import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit' import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit'
import { fetchAPI } from '$utils/api' import { fetchAPI } from '$utils/api'
export async function get({}: RequestEvent): Promise<RequestHandlerOutput> { export async function GET ({}: RequestEvent): Promise<RequestHandlerOutput> {
try { try {
const res = await fetchAPI(` const res = await fetchAPI(`
query { query {

View File

@@ -2,7 +2,7 @@ import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit'
import { fetchAPI } from '$utils/api' import { fetchAPI } from '$utils/api'
import { getRandomItems } from '$utils/functions' import { getRandomItems } from '$utils/functions'
export async function get({}: RequestEvent): Promise<RequestHandlerOutput> { export async function GET ({}: RequestEvent): Promise<RequestHandlerOutput> {
try { try {
// Get total of published photos // Get total of published photos
const totalRes = await fetchAPI(` const totalRes = await fetchAPI(`

View File

@@ -5,7 +5,7 @@ import { fetchAPI } from '$utils/api'
const defaultCountry = String(import.meta.env.VITE_FILTERS_DEFAULT_COUNTRY) const defaultCountry = String(import.meta.env.VITE_FILTERS_DEFAULT_COUNTRY)
const defaultSort = String(import.meta.env.VITE_FILTERS_DEFAULT_SORT) const defaultSort = String(import.meta.env.VITE_FILTERS_DEFAULT_SORT)
export async function get({ url }: RequestEvent): Promise<RequestHandlerOutput> { export async function GET ({ url }: RequestEvent): Promise<RequestHandlerOutput> {
try { try {
// Query parameters // Query parameters
const queryCountry = url.searchParams.get('country') || defaultCountry const queryCountry = url.searchParams.get('country') || defaultCountry

View File

@@ -2,7 +2,7 @@ import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit'
import { fetchAPI } from '$utils/api' import { fetchAPI } from '$utils/api'
import { getProduct } from '$utils/functions/swell' import { getProduct } from '$utils/functions/swell'
export async function get({ params }: RequestEvent): Promise<RequestHandlerOutput> { export async function GET ({ params }: RequestEvent): Promise<RequestHandlerOutput> {
try { try {
// Get content from API // Get content from API
const data = await fetchAPI(` const data = await fetchAPI(`

View File

@@ -3,7 +3,7 @@ import { fetchAPI } from '$utils/api'
import { getRandomItem } from '$utils/functions' import { getRandomItem } from '$utils/functions'
import { getProduct } from '$utils/functions/swell' import { getProduct } from '$utils/functions/swell'
export async function get({}: RequestEvent): Promise<RequestHandlerOutput> { export async function GET ({}: RequestEvent): Promise<RequestHandlerOutput> {
try { try {
// Get content from API // Get content from API
const data = await fetchAPI(` const data = await fetchAPI(`

View File

@@ -1,7 +1,7 @@
import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit' import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit'
import { fetchAPI } from '$utils/api' import { fetchAPI } from '$utils/api'
export async function get({}: RequestEvent): Promise<RequestHandlerOutput> { export async function GET({}: RequestEvent): Promise<RequestHandlerOutput> {
try { try {
const res = await fetchAPI(` const res = await fetchAPI(`
query { query {