Merged in chore/cleanup-unused (pull request #3461)
chore: Cleanup unused vars, exports, types * Cleanup some unused exports * Remove more * Readd CampaignPageIncludedHotelsRef * Add alias comment to procedure exports * Remove unused exports Approved-by: Linus Flood
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { type IntlConfig, IntlProvider } from "react-intl"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export type ClientIntlProviderProps = React.PropsWithChildren<
|
||||
Pick<IntlConfig, "defaultLocale" | "messages"> & { locale: Lang }
|
||||
>
|
||||
|
||||
export default function ClientIntlProvider({
|
||||
children,
|
||||
locale,
|
||||
defaultLocale,
|
||||
messages,
|
||||
}: ClientIntlProviderProps) {
|
||||
return (
|
||||
<IntlProvider
|
||||
locale={locale}
|
||||
defaultLocale={defaultLocale}
|
||||
messages={messages}
|
||||
>
|
||||
{children}
|
||||
</IntlProvider>
|
||||
)
|
||||
}
|
||||
@@ -30,7 +30,7 @@ type LanguageSwitcherProps = {
|
||||
type?: "footer" | "header"
|
||||
}
|
||||
|
||||
export function replaceUrlPart(currentPath: string, newPart: string): string {
|
||||
function replaceUrlPart(currentPath: string, newPart: string): string {
|
||||
const pathSegments = currentPath.split("/").filter((segment) => segment)
|
||||
|
||||
const newPathSegments = newPart
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
"use client"
|
||||
|
||||
import { IntlProvider } from "react-intl"
|
||||
import { type IntlConfig, IntlProvider } from "react-intl"
|
||||
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
import type { ClientIntlProviderProps } from "@/components/IntlProvider"
|
||||
type ClientIntlProviderProps = React.PropsWithChildren<
|
||||
Pick<IntlConfig, "defaultLocale" | "messages"> & { locale: Lang }
|
||||
>
|
||||
|
||||
const logged: Record<string, boolean> = {}
|
||||
|
||||
|
||||
@@ -28,20 +28,6 @@ export function badRequest(cause?: unknown) {
|
||||
)
|
||||
}
|
||||
|
||||
export function notFound(cause?: unknown) {
|
||||
const resInit = {
|
||||
status: 404,
|
||||
statusText: "Not found",
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
cause,
|
||||
},
|
||||
resInit
|
||||
)
|
||||
}
|
||||
|
||||
export function internalServerError(cause?: unknown) {
|
||||
const resInit = {
|
||||
status: 500,
|
||||
@@ -56,20 +42,6 @@ export function internalServerError(cause?: unknown) {
|
||||
)
|
||||
}
|
||||
|
||||
export function serviceUnavailable(cause?: unknown) {
|
||||
const resInit = {
|
||||
status: 503,
|
||||
statusText: "Service Unavailable",
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
cause,
|
||||
},
|
||||
resInit
|
||||
)
|
||||
}
|
||||
|
||||
export function response<T>(data: T, status: number, statusText: string) {
|
||||
return NextResponse.json(data, {
|
||||
status,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { NextRequest } from "next/server"
|
||||
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
import { env } from "@/env/server"
|
||||
|
||||
import type { NextRequest } from "next/server"
|
||||
/**
|
||||
* Use this function when you want to create URLs that are public facing, for
|
||||
* example for redirects or redirectTo query parameters.
|
||||
@@ -44,51 +42,3 @@ export function getPublicURL(request: NextRequest) {
|
||||
}
|
||||
return request.nextUrl.origin
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this function when you want to create URLs that are internal (behind Akamai),
|
||||
* for example for rewrites. Mainly used for middleware wrapped in auth().
|
||||
* The auth() function overrides the origin of the incoming request. It sets it
|
||||
* to the origin of AUTH_URL/NEXTAUTH_URL. This means we cannot use the augmented
|
||||
* request from auth() for rewrites, as those will point to auth url origin
|
||||
* (in front of Akamai) and not the origin of the incoming request (behind Akamai).
|
||||
* This results in rewrites going over the internet instead of going through the
|
||||
* internal routing at Netlify.
|
||||
* For dedicated environments (test, stage and production) we are behind Akamai.
|
||||
* For those we have set a value for AUTH_URL/NEXTAUTH_URL, they point to the
|
||||
* PUBLIC_URL. For rewrites we need the internal origin inside Netlify.
|
||||
* In middleware.ts we copy the incoming origin to a header 'x-sh-origin'. We try
|
||||
* and use that first, if not present we assume the internal origin is the value
|
||||
* of the host header, as that is what Netlify used for routing to this deployment.
|
||||
* @param request The incoming request.
|
||||
* @returns NextURL The internal request, in Netlify behind Akamai.
|
||||
*/
|
||||
export function getInternalNextURL(request: NextRequest) {
|
||||
const { href, origin } = request.nextUrl
|
||||
|
||||
const originHeader = request.headers.get("x-sh-origin")
|
||||
if (originHeader) {
|
||||
logger.debug(`[internalNextUrl] using x-sh-origin header`, {
|
||||
origin,
|
||||
originHeader,
|
||||
newOrigin: href.replace(origin, originHeader),
|
||||
})
|
||||
return new NextRequest(href.replace(origin, originHeader), request).nextUrl
|
||||
}
|
||||
|
||||
const hostHeader = request.headers.get("host")
|
||||
if (hostHeader) {
|
||||
const inputHostOrigin = `${request.nextUrl.protocol}//${hostHeader}`
|
||||
logger.debug(`[internalNextUrl] using host header`, {
|
||||
origin,
|
||||
hostHeader,
|
||||
hostOrigin: inputHostOrigin,
|
||||
newOrigin: href.replace(origin, inputHostOrigin),
|
||||
})
|
||||
const { origin: hostOrigin } = new URL(inputHostOrigin)
|
||||
return new NextRequest(href.replace(origin, hostOrigin), request).nextUrl
|
||||
}
|
||||
|
||||
logger.debug(`[internalNextUrl] falling back to incoming request`)
|
||||
return request.nextUrl
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ export type LangParams = {
|
||||
lang: Lang
|
||||
}
|
||||
|
||||
export type LayoutArgs<P = undefined> = P extends undefined ? {} : Params<P>
|
||||
type LayoutArgs<P = undefined> = P extends undefined ? {} : Params<P>
|
||||
|
||||
export type PageArgs<P = undefined> = LayoutArgs<P> & SearchParams
|
||||
|
||||
Reference in New Issue
Block a user