functionthatreturnsfalse
functionthatreturnsfalse
Explore posts from servers
TTCTheo's Typesafe Cult
Created by functionthatreturnsfalse on 5/14/2023 in #questions
Making sure a dependabot PR doesn't break my project?
Hey ya'll. how can i make sure a dependabot PR doesn't break my project? i'm assuming that upgrading minor versions shouldn't cause too many issues, but i just want to be safe.
3 replies
TTCTheo's Typesafe Cult
Created by functionthatreturnsfalse on 4/5/2023 in #questions
How to define an async procedure?
export const exampleRouter = createTRPCRouter({
hello: publicProcedure
.input(z.object({ text: z.string() }))
.query(({ input }) => {
return {
greeting: `Hello ${input.text}`,
};
}),

getAll: publicProcedure.query(({ ctx }) => {
return ctx.prisma.example.findMany();
}),

getSecretMessage: protectedProcedure.query(() => {
return "you can now see this secret message!";
}),
initAgones: publicProcedure.query(async () => {

const connectRes = await agonesSDK.connect();
console.log({connectRes});

return 'test';
})
});
export const exampleRouter = createTRPCRouter({
hello: publicProcedure
.input(z.object({ text: z.string() }))
.query(({ input }) => {
return {
greeting: `Hello ${input.text}`,
};
}),

getAll: publicProcedure.query(({ ctx }) => {
return ctx.prisma.example.findMany();
}),

getSecretMessage: protectedProcedure.query(() => {
return "you can now see this secret message!";
}),
initAgones: publicProcedure.query(async () => {

const connectRes = await agonesSDK.connect();
console.log({connectRes});

return 'test';
})
});
i'm trying to connect to an SDK asynchronously inside a procedure and it seems to break the entire router, how do i do async things in the procedure?
9 replies
TTCTheo's Typesafe Cult
Created by functionthatreturnsfalse on 2/24/2023 in #questions
Can you run a NextJS project on a closed network?
I would like to run a NextJS project in a closed network that doesn't have access to the internet. Assuming i have all the dependencies already installed, can i just run the project, will it work?
2 replies
TTCTheo's Typesafe Cult
Created by functionthatreturnsfalse on 2/4/2023 in #questions
server component throws error
export default async function BotCommandsSection() {
const commands: BotCommandsResponse = await fetch(
`${BASE_URL}/api/commands`
).then((res) => res.json());
console.log({ commands });

if ('error' in commands) {
return <p>{commands.error}</p>;
}
return commands.map((command) => (
<BotCommandInfo data={command} key={command.id} />
));
}
export default async function BotCommandsSection() {
const commands: BotCommandsResponse = await fetch(
`${BASE_URL}/api/commands`
).then((res) => res.json());
console.log({ commands });

if ('error' in commands) {
return <p>{commands.error}</p>;
}
return commands.map((command) => (
<BotCommandInfo data={command} key={command.id} />
));
}
This server component throws the following error: Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead. Why? i'm writing the server component and fetching data as the nextjs docs mentioned.
3 replies
TTCTheo's Typesafe Cult
Created by functionthatreturnsfalse on 2/3/2023 in #questions
api calls don't work in vercel
I'm trying to call my NextJS API: If I try to write const res = await fetch("/api/commands"); I get the error 'failed to parse URL' despite the API endpoint clearly existing and being accessible via http://localhost:3000/api/commands. To get around this, I declared a base URL variable so I could at least make it work in localhost and hopefully Vercel too (according to Vercel's docs they have a VERCEL_URL that points to the deployment's URL):
export const BASE_URL =
process.env.NODE_ENV === 'development'
? 'http://localhost:3000'
: `https://${process.env.VERCEL_URL}`;
export const BASE_URL =
process.env.NODE_ENV === 'development'
? 'http://localhost:3000'
: `https://${process.env.VERCEL_URL}`;
and then calling the api like so:
const res = await fetch(`${BASE_URL}/api/commands`);
const res = await fetch(`${BASE_URL}/api/commands`);
This works in localhost but not Vercel. How do you properly specify the base URL when calling your API handler?
5 replies
TTCTheo's Typesafe Cult
Created by functionthatreturnsfalse on 1/19/2023 in #questions
TypeError: Failed to parse URL from /api/commands
1 replies
TTCTheo's Typesafe Cult
Created by functionthatreturnsfalse on 1/14/2023 in #questions
prisma.user.create type is 'any'
9 replies