Skip to content

Commit

Permalink
upgrade deps
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgimenes committed Jun 10, 2022
1 parent f0bf084 commit dafc6a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 50 deletions.
27 changes: 2 additions & 25 deletions src/pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,14 @@ export const getServerData = async ({
})

const { execute } = await import('src/server/index')
const { isRedirectError, isNotFoundError } = await import('@faststore/api')
const { isNotFoundError } = await import('@faststore/api')
const { data, errors = [] } = await execute({
operationName: querySSR,
variables: { slug },
})

const redirect = errors.find(isRedirectError)
const notFound = errors.find(isNotFoundError)

if (redirect) {
return {
status: 301,
props: null,
headers: {
'cache-control': ONE_YEAR_CACHE,
location: redirect.extensions.location,
},
}
}

if (notFound) {
return {
status: 301,
Expand All @@ -219,18 +207,7 @@ export const getServerData = async ({
}

if (errors.length > 0) {
throw new Error(`${errors[0]}`)
}

if (data == null) {
return {
status: 301,
props: null,
headers: {
'cache-control': ONE_YEAR_CACHE,
location: `/404/?${params.toString()}}`,
},
}
throw errors[0]
}

return {
Expand Down
27 changes: 2 additions & 25 deletions src/pages/[slug]/p.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,14 @@ export const getServerData = async ({
})

const { execute } = await import('src/server/index')
const { isRedirectError, isNotFoundError } = await import('@faststore/api')
const { isNotFoundError } = await import('@faststore/api')
const { data, errors = [] } = await execute({
operationName: querySSR,
variables: { slug },
})

const redirect = errors.find(isRedirectError)
const notFound = errors.find(isNotFoundError)

if (redirect) {
return {
status: 301,
props: null,
headers: {
'cache-control': ONE_YEAR_CACHE,
location: redirect.extensions.location,
},
}
}

if (notFound) {
return {
status: 301,
Expand All @@ -228,18 +216,7 @@ export const getServerData = async ({
}

if (errors.length > 0) {
throw new Error(`${errors[0]}`)
}

if (data == null) {
return {
status: 301,
props: null,
headers: {
'cache-control': ONE_YEAR_CACHE,
location: `/404/?${params.toString()}}`,
},
}
throw errors[0]
}

return {
Expand Down

0 comments on commit dafc6a9

Please sign in to comment.