mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
Consistent error responses. Updated login page.
This commit is contained in:
parent
88f2ac20bc
commit
4c24e54fdd
17 changed files with 170 additions and 159 deletions
|
|
@ -1,31 +1,40 @@
|
||||||
import { useMessages, useModified } from '@/components/hooks';
|
import { useMessages, useModified } from '@/components/hooks';
|
||||||
import { Button, Icon, Icons, Modal, ModalTrigger, Text, useToasts } from 'react-basics';
|
import {
|
||||||
|
Button,
|
||||||
|
Icon,
|
||||||
|
Icons,
|
||||||
|
Modal,
|
||||||
|
Dialog,
|
||||||
|
DialogTrigger,
|
||||||
|
Text,
|
||||||
|
useToast,
|
||||||
|
} from '@umami/react-zen';
|
||||||
import { WebsiteAddForm } from './WebsiteAddForm';
|
import { WebsiteAddForm } from './WebsiteAddForm';
|
||||||
|
|
||||||
export function WebsiteAddButton({ teamId, onSave }: { teamId: string; onSave?: () => void }) {
|
export function WebsiteAddButton({ teamId, onSave }: { teamId: string; onSave?: () => void }) {
|
||||||
const { formatMessage, labels, messages } = useMessages();
|
const { formatMessage, labels, messages } = useMessages();
|
||||||
const { showToast } = useToasts();
|
const { toast } = useToast();
|
||||||
const { touch } = useModified();
|
const { touch } = useModified();
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
toast(formatMessage(messages.saved));
|
||||||
touch('websites');
|
touch('websites');
|
||||||
onSave?.();
|
onSave?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalTrigger>
|
<DialogTrigger>
|
||||||
<Button data-test="button-website-add" variant="primary">
|
<Button data-test="button-website-add" variant="primary">
|
||||||
<Icon>
|
<Icon>
|
||||||
<Icons.Plus />
|
<Icons.Plus />
|
||||||
</Icon>
|
</Icon>
|
||||||
<Text>{formatMessage(labels.addWebsite)}</Text>
|
<Text>{formatMessage(labels.addWebsite)}</Text>
|
||||||
</Button>
|
</Button>
|
||||||
<Modal title={formatMessage(labels.addWebsite)}>
|
<Modal>
|
||||||
{(close: () => void) => (
|
<Dialog title={formatMessage(labels.addWebsite)}>
|
||||||
<WebsiteAddForm teamId={teamId} onSave={handleSave} onClose={close} />
|
{({ close }) => <WebsiteAddForm teamId={teamId} onSave={handleSave} onClose={close} />}
|
||||||
)}
|
</Dialog>
|
||||||
</Modal>
|
</Modal>
|
||||||
</ModalTrigger>
|
</DialogTrigger>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,4 @@
|
||||||
import {
|
import { Form, FormField, FormSubmitButton, Row, TextField, Button } from '@umami/react-zen';
|
||||||
Form,
|
|
||||||
FormRow,
|
|
||||||
FormInput,
|
|
||||||
FormButtons,
|
|
||||||
TextField,
|
|
||||||
Button,
|
|
||||||
SubmitButton,
|
|
||||||
} from 'react-basics';
|
|
||||||
import { useApi } from '@/components/hooks';
|
import { useApi } from '@/components/hooks';
|
||||||
import { DOMAIN_REGEX } from '@/lib/constants';
|
import { DOMAIN_REGEX } from '@/lib/constants';
|
||||||
import { useMessages } from '@/components/hooks';
|
import { useMessages } from '@/components/hooks';
|
||||||
|
|
@ -36,38 +28,37 @@ export function WebsiteAddForm({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form onSubmit={handleSubmit} error={error}>
|
<Form onSubmit={handleSubmit} error={error?.message}>
|
||||||
<FormRow label={formatMessage(labels.name)}>
|
<FormField
|
||||||
<FormInput
|
label={formatMessage(labels.name)}
|
||||||
data-test="input-name"
|
data-test="input-name"
|
||||||
name="name"
|
name="name"
|
||||||
rules={{ required: formatMessage(labels.required) }}
|
rules={{ required: formatMessage(labels.required) }}
|
||||||
>
|
>
|
||||||
<TextField autoComplete="off" />
|
<TextField autoComplete="off" />
|
||||||
</FormInput>
|
</FormField>
|
||||||
</FormRow>
|
|
||||||
<FormRow label={formatMessage(labels.domain)}>
|
<FormField
|
||||||
<FormInput
|
label={formatMessage(labels.domain)}
|
||||||
data-test="input-domain"
|
data-test="input-domain"
|
||||||
name="domain"
|
name="domain"
|
||||||
rules={{
|
rules={{
|
||||||
required: formatMessage(labels.required),
|
required: formatMessage(labels.required),
|
||||||
pattern: { value: DOMAIN_REGEX, message: formatMessage(messages.invalidDomain) },
|
pattern: { value: DOMAIN_REGEX, message: formatMessage(messages.invalidDomain) },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextField autoComplete="off" />
|
<TextField autoComplete="off" />
|
||||||
</FormInput>
|
</FormField>
|
||||||
</FormRow>
|
<Row justifyContent="flex-end" paddingTop="3" gap="3">
|
||||||
<FormButtons flex>
|
|
||||||
<SubmitButton data-test="button-submit" variant="primary" disabled={false}>
|
|
||||||
{formatMessage(labels.save)}
|
|
||||||
</SubmitButton>
|
|
||||||
{onClose && (
|
{onClose && (
|
||||||
<Button disabled={isPending} onClick={onClose}>
|
<Button isDisabled={isPending} onPress={onClose}>
|
||||||
{formatMessage(labels.cancel)}
|
{formatMessage(labels.cancel)}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</FormButtons>
|
<FormSubmitButton data-test="button-submit" disabled={false}>
|
||||||
|
{formatMessage(labels.save)}
|
||||||
|
</FormSubmitButton>
|
||||||
|
</Row>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import { useMessages } from '@/components/hooks';
|
import { useMessages, useTeamUrl } from '@/components/hooks';
|
||||||
import { PageHeader } from '@/components/layout/PageHeader';
|
import { PageHeader } from '@/components/layout/PageHeader';
|
||||||
import { WebsiteAddButton } from './WebsiteAddButton';
|
import { WebsiteAddButton } from './WebsiteAddButton';
|
||||||
|
|
||||||
export interface WebsitesHeaderProps {
|
export interface WebsitesHeaderProps {
|
||||||
teamId?: string;
|
|
||||||
allowCreate?: boolean;
|
allowCreate?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function WebsitesHeader({ teamId, allowCreate = true }: WebsitesHeaderProps) {
|
export function WebsitesHeader({ allowCreate = true }: WebsitesHeaderProps) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { teamId } = useTeamUrl();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageHeader title={formatMessage(labels.websites)}>
|
<PageHeader title={formatMessage(labels.websites)}>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export function WebsitesPage() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WebsitesHeader teamId={teamId} allowCreate={false} />
|
<WebsitesHeader />
|
||||||
<WebsitesDataTable teamId={teamId} allowEdit={false} />
|
<WebsitesDataTable teamId={teamId} allowEdit={false} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
import { IntlProvider } from 'react-intl';
|
import { IntlProvider } from 'react-intl';
|
||||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||||
import { ZenProvider } from '@umami/react-zen';
|
import { ZenProvider } from '@umami/react-zen';
|
||||||
import { ErrorBoundary } from '@/components/common/ErrorBoundary';
|
|
||||||
import { useLocale } from '@/components/hooks';
|
|
||||||
import 'chartjs-adapter-date-fns';
|
import 'chartjs-adapter-date-fns';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { RouterProvider } from 'react-aria-components';
|
import { RouterProvider } from 'react-aria-components';
|
||||||
|
import { ErrorBoundary } from '@/components/common/ErrorBoundary';
|
||||||
|
import { useLocale } from '@/components/hooks';
|
||||||
|
|
||||||
const client = new QueryClient({
|
const client = new QueryClient({
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export async function POST(request: Request) {
|
||||||
const user = await getUserByUsername(username, { includePassword: true });
|
const user = await getUserByUsername(username, { includePassword: true });
|
||||||
|
|
||||||
if (!user || !checkPassword(password, user.password)) {
|
if (!user || !checkPassword(password, user.password)) {
|
||||||
return unauthorized();
|
return unauthorized({ code: 'incorrect-username-password' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { id, role, createdAt } = user;
|
const { id, role, createdAt } = user;
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
.login {
|
|
||||||
width: 400px;
|
|
||||||
margin: auto;
|
|
||||||
transform: translateY(-25%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
margin: 0 auto;
|
|
||||||
width: 300px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 700;
|
|
||||||
text-align: center;
|
|
||||||
margin: 30px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon svg {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button {
|
|
||||||
flex: 1;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormRow,
|
|
||||||
FormInput,
|
|
||||||
FormButtons,
|
FormButtons,
|
||||||
|
FormField,
|
||||||
|
FormSubmitButton,
|
||||||
TextField,
|
TextField,
|
||||||
PasswordField,
|
PasswordField,
|
||||||
SubmitButton,
|
|
||||||
Icon,
|
Icon,
|
||||||
} from 'react-basics';
|
Column,
|
||||||
|
Heading,
|
||||||
|
} from '@umami/react-zen';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { useApi, useMessages } from '@/components/hooks';
|
import { useApi, useMessages } from '@/components/hooks';
|
||||||
import { setUser } from '@/store/app';
|
import { setUser } from '@/store/app';
|
||||||
import { setClientAuthToken } from '@/lib/client';
|
import { setClientAuthToken } from '@/lib/client';
|
||||||
import Logo from '@/assets/logo.svg';
|
import Logo from '@/assets/logo.svg';
|
||||||
import styles from './LoginForm.module.css';
|
|
||||||
|
|
||||||
export function LoginForm() {
|
export function LoginForm() {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels, getMessage } = useMessages();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { post, useMutation } = useApi();
|
const { post, useMutation } = useApi();
|
||||||
const { mutate, error, isPending } = useMutation({
|
const { mutate, error, isPending } = useMutation({
|
||||||
|
|
@ -35,41 +35,47 @@ export function LoginForm() {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.login}>
|
<Column
|
||||||
<Icon className={styles.icon} size="xl">
|
justifyContent="center"
|
||||||
|
alignItems="center"
|
||||||
|
padding="8"
|
||||||
|
gap="6"
|
||||||
|
backgroundColor="1"
|
||||||
|
borderRadius="3"
|
||||||
|
shadow="3"
|
||||||
|
>
|
||||||
|
<Icon size="lg">
|
||||||
<Logo />
|
<Logo />
|
||||||
</Icon>
|
</Icon>
|
||||||
<div className={styles.title}>umami</div>
|
<Heading>umami</Heading>
|
||||||
<Form className={styles.form} onSubmit={handleSubmit} error={error}>
|
<Form onSubmit={handleSubmit} error={getMessage(error)}>
|
||||||
<FormRow label={formatMessage(labels.username)}>
|
<FormField
|
||||||
<FormInput
|
label={formatMessage(labels.username)}
|
||||||
data-test="input-username"
|
data-test="input-username"
|
||||||
name="username"
|
name="username"
|
||||||
rules={{ required: formatMessage(labels.required) }}
|
rules={{ required: formatMessage(labels.required) }}
|
||||||
>
|
>
|
||||||
<TextField autoComplete="off" />
|
<TextField autoComplete="off" />
|
||||||
</FormInput>
|
</FormField>
|
||||||
</FormRow>
|
<FormField
|
||||||
<FormRow label={formatMessage(labels.password)}>
|
label={formatMessage(labels.password)}
|
||||||
<FormInput
|
data-test="input-password"
|
||||||
data-test="input-password"
|
name="password"
|
||||||
name="password"
|
rules={{ required: formatMessage(labels.required) }}
|
||||||
rules={{ required: formatMessage(labels.required) }}
|
>
|
||||||
>
|
<PasswordField />
|
||||||
<PasswordField />
|
</FormField>
|
||||||
</FormInput>
|
|
||||||
</FormRow>
|
|
||||||
<FormButtons>
|
<FormButtons>
|
||||||
<SubmitButton
|
<FormSubmitButton
|
||||||
data-test="button-submit"
|
data-test="button-submit"
|
||||||
className={styles.button}
|
|
||||||
variant="primary"
|
variant="primary"
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
|
style={{ flex: 1 }}
|
||||||
>
|
>
|
||||||
{formatMessage(labels.login)}
|
{formatMessage(labels.login)}
|
||||||
</SubmitButton>
|
</FormSubmitButton>
|
||||||
</FormButtons>
|
</FormButtons>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</Column>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
.page {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100vh;
|
|
||||||
background: var(--base75);
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
import { Column } from '@umami/react-zen';
|
||||||
import { LoginForm } from './LoginForm';
|
import { LoginForm } from './LoginForm';
|
||||||
import styles from './LoginPage.module.css';
|
|
||||||
|
|
||||||
export function LoginPage() {
|
export function LoginPage() {
|
||||||
if (process.env.disableLogin) {
|
if (process.env.disableLogin) {
|
||||||
|
|
@ -8,8 +8,8 @@ export function LoginPage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.page}>
|
<Column justifyContent="center" alignItems="center" height="100vh" backgroundColor="2">
|
||||||
<LoginForm />
|
<LoginForm />
|
||||||
</div>
|
</Column>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ const selector = (state: { shareToken: { token?: string } }) => state.shareToken
|
||||||
|
|
||||||
async function handleResponse(res: FetchResponse): Promise<any> {
|
async function handleResponse(res: FetchResponse): Promise<any> {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
return Promise.reject(new Error(res.error?.error || res.error || 'Unexpectd error.'));
|
const { message, code } = res?.error?.error || {};
|
||||||
|
return Promise.reject(new Error(code || message || 'Unexpectd error.'));
|
||||||
}
|
}
|
||||||
return Promise.resolve(res.data);
|
return Promise.resolve(res.data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ export function useMessages(): any {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const getMessage = (id: string) => {
|
const getMessage = (id: string) => {
|
||||||
const message = Object.values(messages).find(value => value.id === id);
|
const message = Object.values(messages).find(value => value.id === `message.${id}`);
|
||||||
|
|
||||||
return message ? formatMessage(message) : id;
|
return message ? formatMessage(message) : id;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ export function TeamsButton({
|
||||||
<Row alignItems="center" gap="3">
|
<Row alignItems="center" gap="3">
|
||||||
<Icon>{teamId ? <Users /> : <User />}</Icon>
|
<Icon>{teamId ? <Users /> : <User />}</Icon>
|
||||||
{showText && <Text weight="bold">{teamId ? team?.name : user.username}</Text>}
|
{showText && <Text weight="bold">{teamId ? team?.name : user.username}</Text>}
|
||||||
<Icon rotate={90} size="sm">
|
<Icon rotate={90} size="xs">
|
||||||
<Icons.Chevron />
|
<Icons.Chevron />
|
||||||
</Icon>
|
</Icon>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
import classNames from 'classnames';
|
import { ReactNode } from 'react';
|
||||||
import React, { ReactNode } from 'react';
|
import { Heading, Icon, Breadcrumbs, Breadcrumb, Row } from '@umami/react-zen';
|
||||||
import { Icon } from 'react-basics';
|
|
||||||
import styles from './PageHeader.module.css';
|
|
||||||
|
|
||||||
export function PageHeader({
|
export function PageHeader({
|
||||||
title,
|
title,
|
||||||
icon,
|
icon,
|
||||||
className,
|
|
||||||
breadcrumb,
|
breadcrumb,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
|
|
@ -18,17 +15,15 @@ export function PageHeader({
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.breadcrumb}>{breadcrumb}</div>
|
<Breadcrumbs>
|
||||||
<div className={classNames(styles.header, className)}>
|
<Breadcrumb>{breadcrumb}</Breadcrumb>
|
||||||
{icon && (
|
</Breadcrumbs>
|
||||||
<Icon size="lg" className={styles.icon}>
|
<Row justifyContent="space-between" paddingY="6">
|
||||||
{icon}
|
{icon && <Icon size="lg">{icon}</Icon>}
|
||||||
</Icon>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{title && <div className={styles.title}>{title}</div>}
|
{title && <Heading>{title}</Heading>}
|
||||||
<div className={styles.actions}>{children}</div>
|
<Row justifyContent="flex-end">{children}</Row>
|
||||||
</div>
|
</Row>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -429,4 +429,24 @@ export const messages = defineMessages({
|
||||||
id: 'message.transfer-user-website-to-team',
|
id: 'message.transfer-user-website-to-team',
|
||||||
defaultMessage: 'Select the team to transfer this website to.',
|
defaultMessage: 'Select the team to transfer this website to.',
|
||||||
},
|
},
|
||||||
|
unauthorized: {
|
||||||
|
id: 'message.unauthorized',
|
||||||
|
defaultMessage: 'Unauthorized',
|
||||||
|
},
|
||||||
|
badRequest: {
|
||||||
|
id: 'message.bad-request',
|
||||||
|
defaultMessage: 'Bad request',
|
||||||
|
},
|
||||||
|
forbidden: {
|
||||||
|
id: 'message.forbidden',
|
||||||
|
defaultMessage: 'Forbidden',
|
||||||
|
},
|
||||||
|
notFound: {
|
||||||
|
id: 'message.not-found',
|
||||||
|
defaultMessage: 'Not found',
|
||||||
|
},
|
||||||
|
serverError: {
|
||||||
|
id: 'message.sever-error',
|
||||||
|
defaultMessage: 'Server error',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import { serializeError } from 'serialize-error';
|
|
||||||
|
|
||||||
export function ok() {
|
export function ok() {
|
||||||
return Response.json({ ok: true });
|
return Response.json({ ok: true });
|
||||||
}
|
}
|
||||||
|
|
@ -8,22 +6,53 @@ export function json(data: any) {
|
||||||
return Response.json(data);
|
return Response.json(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function badRequest(error: any = 'Bad request') {
|
export function badRequest(error?: any) {
|
||||||
return Response.json({ error: serializeError(error) }, { status: 400 });
|
return Response.json(
|
||||||
|
{
|
||||||
|
error: { message: 'Bad request', code: 'bad-request', status: 400, ...error },
|
||||||
|
},
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function unauthorized(error: any = 'Unauthorized') {
|
export function unauthorized(error?: any) {
|
||||||
return Response.json({ error: serializeError(error) }, { status: 401 });
|
return Response.json(
|
||||||
|
{
|
||||||
|
error: {
|
||||||
|
message: 'Unauthorized',
|
||||||
|
code: 'unauthorized',
|
||||||
|
status: 401,
|
||||||
|
...error,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ status: 401 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function forbidden(error: any = 'Forbidden') {
|
export function forbidden(error?: any) {
|
||||||
return Response.json({ error: serializeError(error) }, { status: 403 });
|
return Response.json(
|
||||||
|
{ error: { message: 'Forbidden', code: 'forbidden', status: 403, ...error } },
|
||||||
|
{ status: 403 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function notFound(error: any = 'Not found') {
|
export function notFound(error?: any) {
|
||||||
return Response.json({ error: serializeError(error) }, { status: 404 });
|
return Response.json(
|
||||||
|
{ error: { message: 'Not found', code: 'not-found', status: 404, ...error } },
|
||||||
|
{ status: 404 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function serverError(error: any = 'Server error') {
|
export function serverError(error?: any) {
|
||||||
return Response.json({ error: serializeError(error) }, { status: 500 });
|
return Response.json(
|
||||||
|
{
|
||||||
|
error: {
|
||||||
|
message: 'Server error',
|
||||||
|
code: 'server-error',
|
||||||
|
status: 500,
|
||||||
|
...error,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ status: 500 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
html body {
|
html body {
|
||||||
--primary-color: var(--accent-color-blue);
|
--primary-color: #147af3;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue