mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 14:16:19 +00:00
apropiadamente errorear con un id roto
This commit is contained in:
parent
1cc14d0a0b
commit
e30a4904cb
1 changed files with 6 additions and 1 deletions
|
@ -5,8 +5,13 @@ import { and, eq, sql } from 'drizzle-orm';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import * as Sentry from '@sentry/sveltekit';
|
import * as Sentry from '@sentry/sveltekit';
|
||||||
import { formatISO, subDays } from 'date-fns';
|
import { formatISO, subDays } from 'date-fns';
|
||||||
|
import { z } from 'zod';
|
||||||
export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
||||||
const id = BigInt(params.id);
|
const { success, data } = z.object({ id: z.coerce.bigint() }).safeParse(params);
|
||||||
|
if (!success) {
|
||||||
|
return error(400, `Esta URL es inválida`);
|
||||||
|
}
|
||||||
|
const id = data.id;
|
||||||
const aWeekAgo = subDays(new Date(), 5);
|
const aWeekAgo = subDays(new Date(), 5);
|
||||||
const preciosQuery = db
|
const preciosQuery = db
|
||||||
.select({
|
.select({
|
||||||
|
|
Loading…
Reference in a new issue