Sifatul
Sifatul
TTCTheo's Typesafe Cult
Created by danyella on 6/18/2024 in #questions
Get HTMLElement from Element
querySelector() either returns nothing or a dom element. if it does not return an element you can simply use
const el = document.querySelector("#element")
if (!el) {
return
}
const el = document.querySelector("#element")
if (!el) {
return
}
you can then return the element by telling the typescript what it is
return el as ButtonElement
return el as ButtonElement
or retunr the element as HTMLElement.
5 replies
TTCTheo's Typesafe Cult
Created by flow on 6/16/2024 in #questions
stack suggestions
TRPC makes the DX way better. because you get type reference. so you will less likely forget the db schema and your api responses. you can use it but no need to think too much about trpc or not trpc. because you will not forget any of your schema as a MVP is always simple and easy to navigate.
38 replies
TTCTheo's Typesafe Cult
Created by flow on 6/16/2024 in #questions
stack suggestions
yes that's how it's built.
38 replies
TTCTheo's Typesafe Cult
Created by flow on 6/16/2024 in #questions
stack suggestions
one thing I would like to point out. the next.js infact uses express.js like approach when it comes to api. so if you later move to a vps you can copy over all your routes into a different express app and not care too much about scaling next.js app on vercel. just an idea I wanted to share.
import type { NextApiRequest, NextApiResponse } from 'next'

type ResponseData = {
message: string
}

export default function handler(
req: NextApiRequest,
res: NextApiResponse<ResponseData>
) {
res.status(200).json({ message: 'Hello from Next.js!' })
}
import type { NextApiRequest, NextApiResponse } from 'next'

type ResponseData = {
message: string
}

export default function handler(
req: NextApiRequest,
res: NextApiResponse<ResponseData>
) {
res.status(200).json({ message: 'Hello from Next.js!' })
}
38 replies
TTCTheo's Typesafe Cult
Created by flow on 6/16/2024 in #questions
stack suggestions
vercel supports 2 cron jobs at most for free tier. with 13GB disk space for a moderate traffic and regular user less than 1000 a month and less than 100 active perday. I think will be sufficient for vercel
38 replies
TTCTheo's Typesafe Cult
Created by flow on 6/16/2024 in #questions
stack suggestions
yes basically the issue happens when you need to understand image optimization server + frontend separation etc etc. these are all abstructed by vercel.
38 replies
TTCTheo's Typesafe Cult
Created by flow on 6/16/2024 in #questions
stack suggestions
last time I tried to host next.js app out of vercel it caused me pain.
38 replies
TTCTheo's Typesafe Cult
Created by flow on 6/16/2024 in #questions
stack suggestions
or alternatively you can use setTimeout if the cron option is not available.
38 replies
TTCTheo's Typesafe Cult
Created by flow on 6/16/2024 in #questions
stack suggestions
i think vercel has a free tier that lets you to host fullstack apps for free. and if its just a hobby project then dont even worry about vps
38 replies