tsuki
tsuki
Explore posts from servers
DTDrizzle Team
Created by tsuki on 4/8/2024 in #help
trying to create a trigger on supabase to calculate a winrate based on two other columns
No description
6 replies
TTCTheo's Typesafe Cult
Created by tsuki on 3/12/2024 in #questions
Properly setting a minimum delay when fetching data from external api
hi all. i'm trying to use the scryfall api, and they've got a requirement to allow at least 50-100ms of delay between each request to their api. how would i go about properly implementing that? i tried throwing the "whole" thing in a setTimeout() but that doesn't work as i'd expect, as it doesn't actually wait out the timeout and just returns undefined instantly.
import { z } from "zod";

import { createTRPCRouter, publicProcedure } from "~/server/api/trpc";

export const scryfallRouter = createTRPCRouter({
get: publicProcedure
.input(z.object({ name: z.string() }))
.query(async ({ input }) => {
setTimeout(async () => {
console.log("required delay");

const res = await fetch(
`https://api.scryfall.com/cards/named?fuzzy=${input.name}`,
);

if (!res.ok) {
throw new Error("Failed to fetch card");
}

const data = (await res.json()) as unknown;

console.log(data);
return data;
}, 150);
}),
});
import { z } from "zod";

import { createTRPCRouter, publicProcedure } from "~/server/api/trpc";

export const scryfallRouter = createTRPCRouter({
get: publicProcedure
.input(z.object({ name: z.string() }))
.query(async ({ input }) => {
setTimeout(async () => {
console.log("required delay");

const res = await fetch(
`https://api.scryfall.com/cards/named?fuzzy=${input.name}`,
);

if (!res.ok) {
throw new Error("Failed to fetch card");
}

const data = (await res.json()) as unknown;

console.log(data);
return data;
}, 150);
}),
});
i realize the placeholder post router, has something similar but i'm worried it won't actually delay the fetch call like required. any insights/comments are greatly appreciated :JinxHeart:
4 replies
DTDrizzle Team
Created by tsuki on 12/25/2023 in #help
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
i'm trying to start a new project using pnpm and create-t3-app. initial setup goes fine, but once i've linked up with an awake, free-tier, planetscale db and try to run pnpm db:push, an alias for dotenv drizzle-kit push:mysql, i get the following error. i have tried downgrading drizzle-kit to ^0.19.3 as suggested in this thread https://discord.com/channels/1043890932593987624/1188413169668980768/1188647000707694622, which seems to be about a similar issue to mine, but to no avail. any help is greatly appreciated JinxHeart terminal output for good measure:
pnpm db:push

> [email protected] db:push /home/tsuki/projects/tsudo-v3
> dotenv drizzle-kit push:mysql

node:internal/modules/cjs/loader:597
throw e;
^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './relations' is not defined by "exports" in /home/tsuki/projects/tsudo-v3/node_modules/drizzle-orm/package.json
at exportsNotFound (node:internal/modules/esm/resolve:302:10)
at packageExportsResolve (node:internal/modules/esm/resolve:649:9)
at resolveExports (node:internal/modules/cjs/loader:590:36)
at Module._findPath (node:internal/modules/cjs/loader:667:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1129:27)
at Module._load (node:internal/modules/cjs/loader:984:27)
at Module.require (node:internal/modules/cjs/loader:1234:19)
at require (node:internal/modules/helpers:176:18)
at src/introspect-pg.ts (/home/tsuki/projects/tsudo-v3/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:18942:24)
at __init (/home/tsuki/projects/tsudo-v3/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:9:56) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
pnpm db:push

> [email protected] db:push /home/tsuki/projects/tsudo-v3
> dotenv drizzle-kit push:mysql

node:internal/modules/cjs/loader:597
throw e;
^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './relations' is not defined by "exports" in /home/tsuki/projects/tsudo-v3/node_modules/drizzle-orm/package.json
at exportsNotFound (node:internal/modules/esm/resolve:302:10)
at packageExportsResolve (node:internal/modules/esm/resolve:649:9)
at resolveExports (node:internal/modules/cjs/loader:590:36)
at Module._findPath (node:internal/modules/cjs/loader:667:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1129:27)
at Module._load (node:internal/modules/cjs/loader:984:27)
at Module.require (node:internal/modules/cjs/loader:1234:19)
at require (node:internal/modules/helpers:176:18)
at src/introspect-pg.ts (/home/tsuki/projects/tsudo-v3/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:18942:24)
at __init (/home/tsuki/projects/tsudo-v3/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:9:56) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
2 replies
TTCTheo's Typesafe Cult
Created by tsuki on 11/2/2023 in #questions
onSuccess, onError and onSettled deprecated next major version?
No description
16 replies