DivMode
DivMode
Explore posts from servers
DTDrizzle Team
Created by DivMode on 9/28/2023 in #help
sql template string always returns string value
addDate: sql<number>cast (UNIX_TIMESTAMP(${schema.domain.addDate}) as signed), Hi,I have this in a select query but it always returns a string value "1695371020" even though it should be a number. Is there a way to get around it? Im using planetscale.
5 replies
RRailway
Created by DivMode on 9/18/2023 in #✋|help
Bun with turborepo support
Hey guys, Just switched over to bun from fastify but having some trouble setting it up properly to work with railway. Im using turborepo and I just want railway to build the elysia app and I added the nixpacks.toml to root. The nextjs app itself is using vercel. Here is the github repo: https://github.com/DivMode/turbo-test railway server: 4392cf24-3b39-4f8b-a38b-2a47273c234b
[phases.setup]
nixpkgsArchive = 'd68b3b0c914aea10eee7cf2e59ef44e39bc221c9' # https://github.com/NixOS/nixpkgs/commit/d68b3b0c914aea10eee7cf2e59ef44e39bc221c9

[phases.build]
cmds = []

[start]
cmds = ["pnpm run start --filter server"]
[phases.setup]
nixpkgsArchive = 'd68b3b0c914aea10eee7cf2e59ef44e39bc221c9' # https://github.com/NixOS/nixpkgs/commit/d68b3b0c914aea10eee7cf2e59ef44e39bc221c9

[phases.build]
cmds = []

[start]
cmds = ["pnpm run start --filter server"]
22 replies
TTCTheo's Typesafe Cult
Created by DivMode on 8/24/2023 in #questions
Zod not returning undefined
I have this but it looks like zod has a problem returning undefined. I use prisma and I want it to do nothing which prisma does when value is undefined.
created: z.string().nullish().transform((val) => {
return val ? new Date(val) : undefined;
}),
created: z.string().nullish().transform((val) => {
return val ? new Date(val) : undefined;
}),
But get this error
[TypeScript] Types of property 'creationDate' are incompatible.
[TypeScript] Type '(Date | ((params?: RawCreateParams) => ZodUndefined)) & (Date | ((params?: RawCreateParams) => ZodUndefined) | undefined)' is not assignable to type 'string | Date | NullableDateTimeFieldUpdateOperationsInput | null | undefined'.
[TypeScript] Type '(params?: RawCreateParams) => ZodUndefined' is not assignable to type 'string | Date | NullableDateTimeFieldUpdateOperationsInput | null | undefined'.
[TypeScript]
[TypeScript] 308 update: whois
[TypeScript] Types of property 'creationDate' are incompatible.
[TypeScript] Type '(Date | ((params?: RawCreateParams) => ZodUndefined)) & (Date | ((params?: RawCreateParams) => ZodUndefined) | undefined)' is not assignable to type 'string | Date | NullableDateTimeFieldUpdateOperationsInput | null | undefined'.
[TypeScript] Type '(params?: RawCreateParams) => ZodUndefined' is not assignable to type 'string | Date | NullableDateTimeFieldUpdateOperationsInput | null | undefined'.
[TypeScript]
[TypeScript] 308 update: whois
16 replies
TTCTheo's Typesafe Cult
Created by DivMode on 7/11/2023 in #questions
prefetchInfinite not working when inputs are different from useInfinite
Ive been trying to figure out why prefetching doesnt work when the inputs are different between prefetchinfinite and infinitequery. Its works great when the inputs are the same. Hoping someone can shed some light on this.
export const getStaticProps: GetStaticProps<
PageProps,
Query,
PreviewData
> = async (ctx) => {
const { preview = false, previewData = {} } = ctx;

const token = previewData.token;
const [settings, page = fallbackPage] = await Promise.all([
getSettings({ token }),
getHomePage({ token })
]);

const ssg = createServerSideHelpers({
router: appRouter,
ctx: await createContextInner(),
transformer: superjson
});

await ssg.domain.getAll.prefetchInfinite({
recordsPerPage: 40,
query: null,
sorting: [
{
id: "godaddyDomainData.auctionEndTime",
desc: true
}
],
activeAuctions: true,
attributes: attributes,
filters: {
query: {
items: [{ type: "cond", data: {} }]
}
}
});

return {
props: {
trpcState: ssg.dehydrate(),
page,
settings,
preview,
token: previewData.token ?? null
},
revalidate: 3600
};
};
export const getStaticProps: GetStaticProps<
PageProps,
Query,
PreviewData
> = async (ctx) => {
const { preview = false, previewData = {} } = ctx;

const token = previewData.token;
const [settings, page = fallbackPage] = await Promise.all([
getSettings({ token }),
getHomePage({ token })
]);

const ssg = createServerSideHelpers({
router: appRouter,
ctx: await createContextInner(),
transformer: superjson
});

await ssg.domain.getAll.prefetchInfinite({
recordsPerPage: 40,
query: null,
sorting: [
{
id: "godaddyDomainData.auctionEndTime",
desc: true
}
],
activeAuctions: true,
attributes: attributes,
filters: {
query: {
items: [{ type: "cond", data: {} }]
}
}
});

return {
props: {
trpcState: ssg.dehydrate(),
page,
settings,
preview,
token: previewData.token ?? null
},
revalidate: 3600
};
};
const {
data,
hasNextPage,
fetchNextPage,
isError,
isFetching,
isLoading
} = trpc.domain.getAll.useInfiniteQuery(
{
recordsPerPage: 40,
query: debounced,
sorting,
activeAuctions,
attributes: undefined,
filters
},
{
getNextPageParam: (lastPage) => {
// @ts-ignore
const totalPages = Math.floor(
lastPage.estimatedTotalHits / lastPage.limit
);
// @ts-ignore
const actualPage = lastPage.offset / lastPage.limit;
return actualPage < totalPages ? actualPage + 1 : undefined; // By returning undefined if there are no more pages, hasNextPage boolean will be set to false
}
}
);
const {
data,
hasNextPage,
fetchNextPage,
isError,
isFetching,
isLoading
} = trpc.domain.getAll.useInfiniteQuery(
{
recordsPerPage: 40,
query: debounced,
sorting,
activeAuctions,
attributes: undefined,
filters
},
{
getNextPageParam: (lastPage) => {
// @ts-ignore
const totalPages = Math.floor(
lastPage.estimatedTotalHits / lastPage.limit
);
// @ts-ignore
const actualPage = lastPage.offset / lastPage.limit;
return actualPage < totalPages ? actualPage + 1 : undefined; // By returning undefined if there are no more pages, hasNextPage boolean will be set to false
}
}
);
2 replies
TtRPC
Created by DivMode on 7/11/2023 in #❓-help
prefetchinfinite not working when inputs are different
Ive been trying to figure out why prefetching doesnt work when the inputs are different between prefetchinfinite and infinitequery. Its works great when the inputs are the same. Hoping someone can shed some light on this.
export const getStaticProps: GetStaticProps<
PageProps,
Query,
PreviewData
> = async (ctx) => {
const { preview = false, previewData = {} } = ctx;

const token = previewData.token;
const [settings, page = fallbackPage] = await Promise.all([
getSettings({ token }),
getHomePage({ token })
]);

const ssg = createServerSideHelpers({
router: appRouter,
ctx: await createContextInner(),
transformer: superjson
});

await ssg.domain.getAll.prefetchInfinite({
recordsPerPage: 40,
query: null,
sorting: [
{
id: "godaddyDomainData.auctionEndTime",
desc: true
}
],
activeAuctions: true,
attributes: attributes,
filters: {
query: {
items: [{ type: "cond", data: {} }]
}
}
});

return {
props: {
trpcState: ssg.dehydrate(),
page,
settings,
preview,
token: previewData.token ?? null
},
revalidate: 3600
};
};
export const getStaticProps: GetStaticProps<
PageProps,
Query,
PreviewData
> = async (ctx) => {
const { preview = false, previewData = {} } = ctx;

const token = previewData.token;
const [settings, page = fallbackPage] = await Promise.all([
getSettings({ token }),
getHomePage({ token })
]);

const ssg = createServerSideHelpers({
router: appRouter,
ctx: await createContextInner(),
transformer: superjson
});

await ssg.domain.getAll.prefetchInfinite({
recordsPerPage: 40,
query: null,
sorting: [
{
id: "godaddyDomainData.auctionEndTime",
desc: true
}
],
activeAuctions: true,
attributes: attributes,
filters: {
query: {
items: [{ type: "cond", data: {} }]
}
}
});

return {
props: {
trpcState: ssg.dehydrate(),
page,
settings,
preview,
token: previewData.token ?? null
},
revalidate: 3600
};
};
const {
data,
hasNextPage,
fetchNextPage,
isError,
isFetching,
isLoading
} = trpc.domain.getAll.useInfiniteQuery(
{
recordsPerPage: 40,
query: debounced,
sorting,
activeAuctions,
attributes: undefined,
filters
},
{
getNextPageParam: (lastPage) => {
// @ts-ignore
const totalPages = Math.floor(
lastPage.estimatedTotalHits / lastPage.limit
);
// @ts-ignore
const actualPage = lastPage.offset / lastPage.limit;
return actualPage < totalPages ? actualPage + 1 : undefined; // By returning undefined if there are no more pages, hasNextPage boolean will be set to false
}
}
);
const {
data,
hasNextPage,
fetchNextPage,
isError,
isFetching,
isLoading
} = trpc.domain.getAll.useInfiniteQuery(
{
recordsPerPage: 40,
query: debounced,
sorting,
activeAuctions,
attributes: undefined,
filters
},
{
getNextPageParam: (lastPage) => {
// @ts-ignore
const totalPages = Math.floor(
lastPage.estimatedTotalHits / lastPage.limit
);
// @ts-ignore
const actualPage = lastPage.offset / lastPage.limit;
return actualPage < totalPages ? actualPage + 1 : undefined; // By returning undefined if there are no more pages, hasNextPage boolean will be set to false
}
}
);
2 replies
TTCTheo's Typesafe Cult
Created by DivMode on 7/6/2023 in #questions
Regex cutting off anything after space in the url
Heres the current regex : const regex = /(https?://\S+)\s\n\s(Canonical|\d)/g; it gives back: "http://www.stjosephnewwaverlytx.net/Religious" want it to give me the full url: "http://www.stjosephnewwaverlytx.net/Religious" + " Education/Teachers and Staff/Lessons/Misc/Sacraments.jpg Tried for a couple of hours to get it working but with no luck. Any help would be appreciated. Thanks!
5 replies
TTCTheo's Typesafe Cult
Created by DivMode on 3/8/2023 in #questions
prefetchInfinite causing query on initial load
I am prefetching the data in getStaticProps and it fetches on initial load even with staletime set to infinity. https://www.loom.com/share/454e3d2b75fa426d923e119775d1086c
4 replies
TTCTheo's Typesafe Cult
Created by DivMode on 11/1/2022 in #questions
No longer able to set background images in css with nextjs 13?
3 replies