Steven-sensei
Steven-sensei
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Steven-sensei on 9/27/2024 in #questions
Free VPS for students
Hi, I was wondering if you know of any free VPS hosting options for students. I'm not really a fan of Linode since their offer is only for two months with $100 in credits, but I need a VPS for around three months. The server doesn't need to be super powerful—just enough to host a PostgreSQL database and a Next.js site.
19 replies
HHono
Created by Steven-sensei on 9/16/2024 in #help
Integration testing with test client and HTTP only cookies
Hello, I have an API with HTTP only cookies built with Hono (Behind Next.js https://hono.dev/docs/getting-started/vercel). I tried to do some integration testing with Hono test client and vitest. I ran into a big issue that is my HTTP only cookies aren't send back to the server. It's normal since HTTP only behavior is handle by the browser and not Node or bun. So I was wondering what tooling or how could i do this integration testing. I want to run it in my CI CD. Any idea or recommendation is welcome ^^
import { config } from 'dotenv';
import { testClient } from 'hono/testing';
import { describe, expect, test } from 'vitest';

import app, { AppRoutes } from './app/api/[[...route]]/route';

describe('demo', () => {
config();
test('should work', async () => {
const client = testClient<AppRoutes>(app);
const res = await client.api.auth.login.$post(
{
json: {
password: '#Password123',
},
},
{
init: {
credentials: 'include',
},
}
);
console.log(await res.json());
const res2 = await client.api.auth.me.$get(undefined, {
init: {
credentials: 'include',
},
});
//Work !
expect(res.status).toBe(201);
// 401 No cookies has been send
expect(res2.status).toBe(200);

});
});
import { config } from 'dotenv';
import { testClient } from 'hono/testing';
import { describe, expect, test } from 'vitest';

import app, { AppRoutes } from './app/api/[[...route]]/route';

describe('demo', () => {
config();
test('should work', async () => {
const client = testClient<AppRoutes>(app);
const res = await client.api.auth.login.$post(
{
json: {
password: '#Password123',
},
},
{
init: {
credentials: 'include',
},
}
);
console.log(await res.json());
const res2 = await client.api.auth.me.$get(undefined, {
init: {
credentials: 'include',
},
});
//Work !
expect(res.status).toBe(201);
// 401 No cookies has been send
expect(res2.status).toBe(200);

});
});
And with a console log in my middleware i seed that my cookie is not being send
6 replies
TTCTheo's Typesafe Cult
Created by Steven-sensei on 6/27/2024 in #questions
Shadcn Dialog + Form Error: React.Children.only
Hello, I'm want to use a From from shadcn inside a dialog from shadcn but I have this error : Error: React.Children.only expected to receive a single React element child. I don't really understand why it's the case I belive the error is caused by the <Form>
"use client";
import React from "react";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";

import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";

import { z } from "zod";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";

export default function CreateOrJoinGame({
children,
}: {
children: React.ReactNode;
}) {
return (
<Dialog>
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Make changes to your profile here. Click save when you're done.
</DialogDescription>
</DialogHeader>
<>
<CreateGameDialog />
</>
</DialogContent>
</Dialog>
);
}
"use client";
import React from "react";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";

import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";

import { z } from "zod";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";

export default function CreateOrJoinGame({
children,
}: {
children: React.ReactNode;
}) {
return (
<Dialog>
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Make changes to your profile here. Click save when you're done.
</DialogDescription>
</DialogHeader>
<>
<CreateGameDialog />
</>
</DialogContent>
</Dialog>
);
}
5 replies
TTCTheo's Typesafe Cult
Created by Steven-sensei on 8/6/2023 in #questions
Why keyof Record wont actually give the keys of the record ?
I have this exemple :
type GlobalStuff = {
description : C,
validate : (descriptionKeys : Record<keyof C, string> | undefined) => Boolean
}

type C = Record<string,object>


const test : GlobalStuff = {
description : {
test: {}
},
validate : (descriptionKeys) => {
//no auto completed
descriptionKeys.test
return true
}
}
type GlobalStuff = {
description : C,
validate : (descriptionKeys : Record<keyof C, string> | undefined) => Boolean
}

type C = Record<string,object>


const test : GlobalStuff = {
description : {
test: {}
},
validate : (descriptionKeys) => {
//no auto completed
descriptionKeys.test
return true
}
}
So based on what i describe with type i would have hope that descriptionsKeys would get auto completion base on the description the user give but it doesn't thinkies The type of descriptionKeys is Record<string, string> and not Record<"test" , string> and if i had more keys to desc i would hope to get these keys to in the Record. Any idea of where i m wrong ?
17 replies