Jokcy
Jokcy
Explore posts from servers
CDCloudflare Developers
Created by Jokcy on 4/25/2024 in #pages-help
Got Error 9412 when intergate with cloudflare transform-images
Here is my origin image https://pub-ca47892bad5a4ac188639b2876730708.r2.dev/test-imb%2F%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230922092202 I try to use cloudflare images transform-images feature to resize my origin image by: https://coolify.jokcy.fun/cdn-cgi/image/width=80https://pub-ca47892bad5a4ac188639b2876730708.r2.dev/test-imb%2F%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230922092202 I already enabled this feature on my zone: jokcy.fun, I got this error:
ERROR 9412: Could not resize the image: Unknown or unsupported file type
ERROR 9412: Could not resize the image: Unknown or unsupported file type
How can I make it work?
7 replies
DTDrizzle Team
Created by Jokcy on 1/30/2024 in #help
Insert into sqlite3 with better-sqlite3 not working
The drizzle logger out put:
Query: insert into "todos" ("id", "title", "completed", "created_at") values (null, ?, ?, ?) returning "id", "title", "completed", "created_at" -- params: ["asd", 0, 1706613150]
Query: insert into "todos" ("id", "title", "completed", "created_at") values (null, ?, ?, ?) returning "id", "title", "completed", "created_at" -- params: ["asd", 0, 1706613150]
Drizzle function call:
const x = await db
.insert(todos)
.values({
title: text,
createdAt: new Date(),
})
.returning()
.execute();
const x = await db
.insert(todos)
.values({
title: text,
createdAt: new Date(),
})
.returning()
.execute();
DB:
const sqlite = new Database(join(process.cwd(), "./db.sqlite"));
_db = drizzle(sqlite, {
schema,
logger: true,
});
const sqlite = new Database(join(process.cwd(), "./db.sqlite"));
_db = drizzle(sqlite, {
schema,
logger: true,
});
All seems good but no data being inserted into db, what might be wrong? Code here: https://github.com/Jokcy/solidstart-cf
6 replies
TtRPC
Created by Jokcy on 10/28/2023 in #❓-help
Is there any easy way to create a Type for a trpc router
I want to publish a set of trpc api client to npm, which will be used by my customer directly. But if I use typeof MyRouter to infer the Router type, my bundler (which is tsup) will bundle db schema types into the d.ts file. If I want my customer to gain the typesafe ability I have to make my db schema info public. Is there any way to define a Router type without typeof MyRouter type infer? So that I can expose limited info to public.
3 replies
CDCloudflare Developers
Created by Jokcy on 6/23/2023 in #pages-help
Why requests from china will be route to US?
I tested my pages on china, I found all requests being routed to US instead Asia endpoints. I have to manually set my domain record to one of the ip of Asia, it's much faster than the default route. How can I make the requests from china being routed correctly?
6 replies
CDCloudflare Developers
Created by Jokcy on 6/1/2023 in #pages-help
wrangler pages dev stuck without any output
1 replies
TtRPC
Created by Jokcy on 2/27/2023 in #❓-help
Cache not working for `useQuery`
I have a query like this:
const { data: article, isFetching } = api.public.getArticle.useQuery({
id: targetId,
});
const { data: article, isFetching } = api.public.getArticle.useQuery({
id: targetId,
});
which targetId is a dynamic value. When I change targetId from a to b then switch back from b to a, the useQuery hook still send a new request for a instead of using cache. Any idea how to make the cache work?
6 replies
TtRPC
Created by Jokcy on 1/22/2023 in #❓-help
Demo code `trpc.infinitePosts.add` on infinitedQuery not working
Doc here: https://trpc.io/docs/useInfiniteQuery#getinfinitedata, I created an my query like this:
infinitePosts: protectedProcedure
.input(
z.object({
limit: z.number().min(1).max(100).nullish(),
cursor: z.string().nullish(), // <-- "cursor" needs to exist, but can be any type
})
)
.query(async ({ ctx, input }) => {
const limit = input.limit ?? 20;
const { cursor } = input;
const items = await ctx.prisma.post.findMany({
take: limit + 1, // get an extra item at the end which we'll use as next cursor
cursor: cursor ? { id: cursor } : undefined,
orderBy: {
updatedAt: 'asc',
},
});
let nextCursor: typeof cursor | undefined = undefined;
if (items.length > limit) {
const nextItem = items.pop();
nextCursor = nextItem!.id;
}
return {
items,
nextCursor,
};
}),
infinitePosts: protectedProcedure
.input(
z.object({
limit: z.number().min(1).max(100).nullish(),
cursor: z.string().nullish(), // <-- "cursor" needs to exist, but can be any type
})
)
.query(async ({ ctx, input }) => {
const limit = input.limit ?? 20;
const { cursor } = input;
const items = await ctx.prisma.post.findMany({
take: limit + 1, // get an extra item at the end which we'll use as next cursor
cursor: cursor ? { id: cursor } : undefined,
orderBy: {
updatedAt: 'asc',
},
});
let nextCursor: typeof cursor | undefined = undefined;
if (items.length > limit) {
const nextItem = items.pop();
nextCursor = nextItem!.id;
}
return {
items,
nextCursor,
};
}),
Then on my client: api.post.infinitePosts, but there is no .add or .delete on it, am I miss something or is there any detail doc?
1 replies