#development

1 messages · Page 275 of 1

hard wraith
#

ill work off 21% the original amount and adjust from there

ivory hawk
hard wraith
#

not bad, just under $1 when you add the $3 to the user's ai use.

ivory hawk
#

Cause 30% is high

hard wraith
ivory hawk
#

So once you hit the standard tier...

#

That's 36%

hard wraith
#

You only get charged 30% when you are over a million dollars at which point, are you worried about 36%?

ivory hawk
#

Oh lol

hard wraith
#

yeah lmao

#

still a lot given we provide all the services at cost to us at that point and most bots only charge back what it costs to use those features

#

before this the £5 was the total amount of ai cost you could use.

#

now i have to cut it to £3 to account for the discord fee

#

And that sucks because I still wanted to charge the same on the website and give the same amount of credits, but cant as that would breach discord monetization policy

ivory hawk
#

Ye

hard wraith
#

I mean, its all the same to me, but sucks for my users as they just lost £2 of credits and thats a lot.

ivory hawk
#

Well does it have to be after percentages or could you show a flat rate of 5 dollars

hard wraith
#

the amount you select is $4.99 you cant do whole round values

ivory hawk
#

And then do 4.99 on the site?

hard wraith
#

and then I can only let users use the amount of money I get from discord else I lose money on ai cost.

ivory hawk
#

If you show 4.99 on both, you would still be profiting from site. No one uses the discord subs

hard wraith
#

oh the prices will be the same... but i cant offer users $4.99 of credits for ai on the website and only $3 of credits on discord.

ivory hawk
#

Flat rate of 3 then

hard wraith
#

which is what sucks about this policy because the users lost a lot of credits

ivory hawk
#

You could profit 2 towards server costs and stuff

hard wraith
#

my other projects already pay for the servers i use... i dont have those costs anymore

#

and the most expensive functions are done on cloudflare workers and i have a deal with them

ivory hawk
#

How many bots do you own that generate revenue lol

hard wraith
#

1

ivory hawk
#

Dang

hard wraith
#

I make SaaS apps.

ivory hawk
#

Oh that makes sense if ur deploying on cloudflare

hard wraith
#

i have an ai chatbot website that makes enough to pay for the servers for it and my bot

ivory hawk
#

Dang lol

hard wraith
#

no? the bot is on linode... the api is on workers lol

ivory hawk
#

I use cloudflare for their d1, and r2

hard wraith
#

linode is cheap af too... $5 a month for a server that will happily run a discord bot in 100 servers

#

i think the most expensive server I have with them is $15 a month for a self hosted redis server and then a $10 a month server running postgres

ivory hawk
#

I host my own cause an old laptop works quite stellar lol

hard wraith
#

so $30 a month to host everything i need comfortably.

ivory hawk
#

Nice. I pay 0 a month rn. Cloudflares r2 handles anything between the site and bot and then the bot has a local db for everything else

hard wraith
#

ye the cloudflare free tier is super generous

ivory hawk
#

And then my site is on vercel free hosting

hard wraith
#

I havent had to pay anything for the 5 apis on it yet and one of them got hit hard the other day

#

still 0 cost.

ivory hawk
#

Ye they are very generous

#

I use the r2 bucket for public transcripts

hard wraith
neon leaf
#

am I using cloudflare from temu or something

hard wraith
#

prolly

neon leaf
#

I only had problems with workers and d1 especially

hard wraith
#

lmao

ivory hawk
hard wraith
#

oh workers is updated like daily

neon leaf
#

over 5h downtime per month on d1

ivory hawk
#

Oh... my d1 is 100% up

#

Very generous there too with the reads and writes

hard wraith
neon leaf
#

yeah I did switch away a few months ago

#

best decision for my project

#

response times went from 500ms to 89ms

ivory hawk
#

For d1?

hard wraith
#

d1 is a database right?

ivory hawk
#

500ms is crazy

hard wraith
#

just go to upstash

neon leaf
#

yes, d1 is a db

hard wraith
#

or neon

ivory hawk
neon leaf
#

I just have my own pg replication setup with 6 nodes now

ivory hawk
#

Odd it was 500 ms for a db

neon leaf
#

more expensive yes, more reliable, yes

ivory hawk
#

Mine is almost instant for dbs

hard wraith
#

hell prisma have their own postgres stuff and accelerate is really good to use for speeding up apps.

neon leaf
#

prisma has also been pretty slow in my experience

hard wraith
#

im migrating all my apps to use prisma accelerate for speed.

ivory hawk
#

Actually

neon leaf
#

switching from prisma to drizzle was instant 50ms gain

ivory hawk
#

I think d1 is probably slow

neon leaf
#

not all obv

#

but most did improve

ivory hawk
#

I dont do much besides update server stuff and commits

hard wraith
#

i hate how drizzle does the data response tho

#

their orm just rubs me the wrong way

neon leaf
#

its not really an orm

#

its more a query builder

hard wraith
#

and prisma with accelerate is faster than drizzle.

neon leaf
#

🤷 I dont use either anymore

#

I switched to rust

hard wraith
#

lmao

#

ive been looking at go

neon leaf
#

I mean I do use drizzle for db migrations because my project has tons of tech debt still in ts

hard wraith
#

go fits me better as I am a typescript first dev

neon leaf
#

and im not rewriting another 100k lines

hard wraith
#

ye f that

neon leaf
#

all the api stuff is rust

#

rest doesnt matter that much

#

🙏

hard wraith
#

ive been debating go for api... whats the comparison between a rust api and go api~?

neon leaf
#

well, go is a lot simpler

#

you dont need to worry about sharing data etc

#

it does most locking/sharing for you

#

(like ts)

hard wraith
#

Thats h

neon leaf
#

in rust, everything is explicit

hard wraith
#

Why i picked it

#

i meant speed and durability wise

neon leaf
#

yeah go and rust are close

#

for an api likely pretty equal

#

might have a smaller memory footprint with rust but not that big of a diff

hard wraith
#

which one does cloudflare workers support? lmao

neon leaf
#

both are supported afaik

#

(rust im 100% sure, using wasm)

hard wraith
#

workers is v8 so I hope so

#

its not node, its not rust or go... its something inbetween

neon leaf
#

v8 is the runtime used by node

hard wraith
#

ye

neon leaf
#

seems like go is not in the docs

hard wraith
#

I might just stick with ts for now, speed isnt a huge issue currently. But if my bot blows up when i add it here... I might have to rewrite the api in rust or go

#

shid... rust it is... F.

neon leaf
#

I wouldnt recommend rust on a worker though

#

unless you are doing heavy cpu-related stuff

hard wraith
#

ye it seems typescript and javascript oriented

neon leaf
#

because rust workers are not that much faster than a js-based one

#

(rust workers use js to run)

hard wraith
#

tf

#

lmao

#

ok thats funny

neon leaf
#

yeah your rust is compiled to wasm (WebAssembly)

#

then its loaded by js

#

and ran

hard wraith
#

ts and js are being reworked into a go runtime

#

So workers might have to update soon

neon leaf
#

nah thats just the transpiler

#

not the runtime

hard wraith
#

oh shid right... it all just goes down to plain minified js anyways

#

i stopped using js entirely for ts that i forgot ts isnt its own language, its just typesafe js lmao

prime cliff
#

Yea i call bs on that 10x performance unless typescript really fked up something

neon leaf
#

nah you can test it yourself

#

the "compiler" (transpiler & type-checker) is 10x faster

#

writing a parser and type-checker in js was not a good idea

quartz kindle
prime cliff
#

I mean if that's the case then they are just admitting javascript is slower xD

neon leaf
neon leaf
#

pretty obvious

#

compiled vs jitted

neon leaf
#

go and ts are very similar so most code is literally copy pasted

#

so they can preserve the same parsing jankiness

quartz kindle
#

rewriting would be writing from scratch, aka different from the original

neon leaf
#

yes

#

not possible with c++

#

too different of a lang

prime cliff
#

Time to code break things :>)

quartz kindle
neon leaf
#

arrrr so close to <100ms

misty sigil
#

does it need to be <100ms

timber hatch
#

I'm currently hosting a NextJS project on vercel using authjs with a mongo adapter.

I'm running into an issue where frequent session revalidations are causing rate limits on my mongo cluster.

Does anyone have a reasonable solution. I've considered self hosting, JWT, or upgrading the cluster but i'm not sure which solution is more appropriate.

Thanks in advance :)

hard wraith
hard wraith
#

put a redis infront of the db calls.

#

will also speed up your performance a little bit

neon leaf
#

ive done everything

#

but filtering through 2mil rows is still pretty slow

hard wraith
#

Did you give it a better cpu, more ram and a 5090?

#

You need you one of those chtgpt servers

neon leaf
#

yes yes

hard wraith
#

i think its just a cool 100k for that gpu they use in one server lol

#

im still tweaking clerkXdiscord link and then passing the data to my backend to monitor user plans

#

because I forgot a user can have an account without being logged into the dashboard.

#
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
}

enum Plans {
  FREE
  PREMIUM // 0 premium server included. 500 ai messages a day.
  PREMIUMPLUS // 1 premium server included. 1000 ai messages a day.
  PRO // 3 premium servers included. 1500 ai messages a day.
}

enum LogLevel {
  MINIMAL // only moderator commands like ban and kick
  MEDIUM // included deleted messages and join/leave
  MAXIMUM // include edited messages and user updates (username, role etc.)
}

model Users {
  id             String    @id @default(cuid())
  username       String    @unique
  email          String    @unique
  extId          String?   @unique
  discordId      String?   @unique
  plan           Plans     @default(FREE)
  Limits         Limits?
  premiumServers Servers[]
}

model Limits {
  id                  String   @id
  date                DateTime
  aiUsed              Int      @default(0)
  aiLimit             Int      @default(20)
  premiumServers      Int      @default(0)
  premiumServerLimmit Int      @default(0)
  user                Users    @relation(fields: [id], references: [id])
}

model Servers {
  id                  String   @id
  name                String
  ownerId             String
  isPremium           Boolean  @default(false)
  premiumAddedBy      String?
  premiumUser         Users?   @relation(fields: [premiumAddedBy], references: [discordId])
  aiEnabled           Boolean  @default(false)
  welcomeChannel      String?
  announcementChannel String?
  updatesChannel      String
  logsChannel         String
  logLevel            LogLevel @default(MINIMAL)
}
```if you know anything about prisma... db is fun again... But my god is it angry when you mess up.
#

I think I need to tweak it more, but this will change a lot of bot functionality so i think I have to hold off on putting my bot on topgg as the dashboard redesign is changing how servers and users are recorded.

hard wraith
#

~10ms db query time

neon leaf
#

weak numbers

#

ttl=64 time=0.050 ms

hard wraith
#

This is with the use of api calls and on a dev environment lol

#

when used on servers in prod, with all the api calls etc a single process is ~5ms

#

as its hosted close to where the db is.

#

10ms total time on dev in another country with slower api calls on my dev machine was pretty nice tbf.

#

if i wanted faster I could probably go with go and some other stuff, use a nosql method etc...

#

but F that.

neon leaf
#

nosql is NOT faster for this kind of data

#

🙏

hard wraith
#

true...

#

idk how to make it faster unless I go direct with neon serverless

#

but accelerate adds in caching for requests so it can speed up data return times on commonly accessed data

#

its like adding redis infront of it, sorta.

#

Just not as fast as using redis

#

If you know a faster way to handle the data processing in typescript on cloudflare workers I am all ears. But remember I self host postgres lmao.

neon leaf
#

1/6 nodes

hard wraith
#

Interesting.

#

And that's using what?

neon leaf
#

postgres + redis + rust 🚀

hard wraith
#

so basically what I do with prisma and accelerate

#

on my ts worker

neon leaf
#

yes but with higher db ping

hard wraith
#

but faster

neon leaf
#

i have 0.05ms ping to db

#

on every node

hard wraith
#

id have to check

neon leaf
#

I may dump redis for the general cache though, its much faster storing cache in rust hashmaps

hard wraith
#

neon dev database is the bottleneck

#

Thats abysmal that accelerate is saying 828ms but the entire data fetch process only took 15ms and 5 of that was processing the data on the worker...

#

Something is lying to me and I dont think it was the request time data on the dev console on wrangler

#

I always use this as source of truth on process durations

neon leaf
#

seems to line up with prisma

#

~800ms average

hard wraith
#

Funny because I dont even call the database here

#

Thats all just calling the discord and clerk apis

#

Wait my db is empty... i forgot i cleared it to push the new changes... rip.

#

lmao

#

It probably keeps trying requests with no data wondering why its returning nothing when there were no requests through accelerate to delete data as I did it on the db and clerk ends

#

I keep being pushed towards drizzle but the output is just... meh

hard wraith
#

ok ew... prisma makes you generate the client into your src directory now... so you cannot ignore it.

prime cliff
#

vibecat Woo import feature

solemn latch
#

I am an import feature?

delicate zephyr
#

@prime cliff this better be stable soon

#

or imma be crying

#

I have too many vms to manage kekW

#

finally did the server migration

prime cliff
#

I mean you can technically use it atm and try it out mmLol break a few things

delicate zephyr
#

that would be using it in production

prime cliff
delicate zephyr
#

which ive been told im not allowed to do with topstats :^)

hard wraith
#

lmaooooo

#

break everything test important experiment and upcoming features

delicate zephyr
#

im so close to being finished with migration man

hard wraith
#

sounds like pain

#

you didnt make a tool to help you?

delicate zephyr
#

its taken 4 days

delicate zephyr
#

a lot harder than you'd expect

#

:^)

hard wraith
#

ye... i work in devops... ik

#

lmao

delicate zephyr
#

Yea

#

I made my own pain

#

fixed it tho

hard wraith
#

i made a tool to help me. it just pushes it to my colleagues ticket queue

delicate zephyr
hard wraith
#

"Oh this server is a paina nd i dont wanan do it" press the shove to my hated colleague

delicate zephyr
#

see

hard wraith
#

ew

delicate zephyr
#

im saving like 40euro a month doing this

#

so

hard wraith
#

yeah you made your own hell

delicate zephyr
#

now its on proxmox in vms

#

like is better now

#

and we have a firewall that works

hard wraith
#

ok cool... i just use pm2 cus node apps

delicate zephyr
#

we use docker/proxmox

#

I'll eventually learn kube

hard wraith
#

Tho i think the pipeline spins up a linode server or a kubernete not sure which with pm2 on to launch and build the app

delicate zephyr
#

memory usage is pog tho

quartz kindle
#

ram go brrr

#

enough to run discord.js

hard wraith
#

112 gb

#

jesus

delicate zephyr
#

to an AX102 with 196GB of ram

#

+22TB HDD

hard wraith
#

why hdd?

delicate zephyr
#

now sharing a server with Marco and Tonkku again

#

Marco runs a peertube

#
  • VM backups
hard wraith
#

hdd should be used on a deep store not a live server

delicate zephyr
#

we have 2TB of nvme

delicate zephyr
hard wraith
#

unless you also have nvme ssd on it and the hdd is used to store long term data

quartz kindle
#

tape storage > all

hard wraith
#

tape is goated

delicate zephyr
hard wraith
#

the uk government website still loads some data from tape drives

delicate zephyr
#

HDD for backup / process only (stateless) services

hard wraith
#

they havent digitised and updated everything either... so we have paper records people have to find too

solemn latch
#

tape drives are still used ^-^

delicate zephyr
#

tape drives are cool ngl

solemn latch
#

yeah

#

the fact they're still great long term mass storage is wild

hard wraith
#

I wish I could add a tape drive to my pc just for fun

quartz kindle
#

who would have known that tape tech would evolve so much

#

50tb in a single tape

solemn latch
delicate zephyr
#

albeit slow

solemn latch
#

Modern tapes are more expensive than SSD's now

hard wraith
#

if tape is still as expensive as a 50tb nvme ssd server then i will eat that cost

delicate zephyr
#

yea but atleast tap doesn't just die out of nowhere

#

you can shove it in a cupboard for 100 years and know it'll be fine as long as conditions didnt get too extreme

#

lmao

hard wraith
#

so a 3d printer fillament storage device for the tapes

#

keeps the area cool and dry

#

and dust free

#

damnit youtube keeps putting 4 adverts on and im just like "ok i get it, you want me to renew premium"

misty sigil
#

my friend has 10g fibre to his

#

10g fibre between their rack nas and proxmox then to the pc

#

so if you can do that you can do tapes

prime cliff
#

Doing a proper editor too with text and formatting options 🙂

delicate zephyr
#

I finish migrations

#

im so fucking happy

prime cliff
#

Hmm i could actually do a nice editor diff toggle for compose too, to compare the previous and new version while you edit

ivory hawk
#

Nice!

hard wraith
delicate zephyr
#

I'd rather be doing that

#

I've drowned in this the last 4 days

hard wraith
#

I hate front end

delicate zephyr
#

4 days of 8 hours roughly a day just migrating machines

hard wraith
#

I don’t use ai to code so… it sucked… I spent 3 hours figuring out what changed in tailwind v4.1 just to make it animate in properly

delicate zephyr
#

sounds about right lol

#

I know the pain

#

I also know Xig has a lot of fun getting topstats to work with our styling with tailwind

hard wraith
#

The 1 second animation was brutal so now it’s 500ms

#

I’ve gotta figure out how I can make it load each card one at a time with a 100ms delay so it looks like they are being pushed onto the dashboard instead of just appearing after a loading spinner

delicate zephyr
#

feels so wrong to have an empty server

#

this used to have 100GB ram usage

hard wraith
#

I bet 😂

delicate zephyr
#

it's fine

#

I moved it

hard wraith
#

GGs tho

#

Oh shid this is gonna be hosted on vercel… and images run on… ima go broke.

delicate zephyr
#

upload the images to cloudflare r2

#

its free for the most part afaik

hard wraith
#

It’s not that the next/image component preloads images… meaning it also puts them on vercel stuff

#

Plus the images come from the discord cdn 😂

#

Now to turn off word wrap now not making a super long class name just to animate stuff 😂

ivory hawk
hard wraith
#

5gb

ivory hawk
#

Ye

hard wraith
#

Not that large, but good enough for free

#

and its cheap af for anything over

#

Cheaper than s3 and the azure options

ivory hawk
hard wraith
#

yup

#

I think this for a simple dashboard home page might be a bit simple... But I dont want to make it too complicated lol

#

I know I need a navbar and a sidebar but thats just... complicated stuff.

ivory hawk
#

What images are you saving?

hard wraith
#

None

#

But the image component from Next/Image does some pre-rendering that gets expensive for a lot of images on vercel.

ivory hawk
#

Hmmm, I use vercel and havent had an issue with server avatars

hard wraith
#

I might have to look at the just released way to host on cloudflare as it wond have that cost

hard wraith
#

Theo was talking about it before on why he hosts off of vercel.

ivory hawk
#

I'll have to take a peek

hard wraith
#

And he went and made t3chat so... you know he knows what he talking about.

ivory hawk
#

Cloudflare doesnt do TS do they?

delicate zephyr
#

this is gona take while

ivory hawk
#

Once I get my own apartment I'm putting a rack and switch in lol

delicate zephyr
#

but running servers on residential internet is a bit iffy

hard wraith
delicate zephyr
hard wraith
#

Have for ages?

delicate zephyr
#

especially if it's intended to make profit

ivory hawk
delicate zephyr
#

I almost got my wifi disconnected at one point

hard wraith
#

When was the last time you touched workers? It’s v8 JavaScript stuff and has always worked with typescript. 😂

ivory hawk
#

They havent yelled at me yet. I have a web server and a bot server running rn

delicate zephyr
#

this was my first year at hetzner

delicate zephyr
#

3-4TB traffic a month on average

ivory hawk
#

Damn

delicate zephyr
#

dipped for a bit

hard wraith
#

Rookie numbers

delicate zephyr
#

then shot up to 5-6TB a month last year

#

and it's only increasing now lol

ivory hawk
delicate zephyr
#

partially because of how much data we pull from top.gg

#

but mmulu

hard wraith
ivory hawk
#

So you could hypothetically export vercel stuff and just import and run?

delicate zephyr
#

we pull down 9TB of data alone from top.gg a year

#

lmao

hard wraith
#

With some minor changes… you’d have to read the docs.

ivory hawk
#

Oh ik, I've been fighting with their d1 lol

#

There d1 doesnt support some generic prisma db stuff

hard wraith
#

Cloudflare made an app that makes your internet faster and safer? Hell yeah.

ivory hawk
#

Which?

hard wraith
#

Their 1.1.1.1 site

#

Called warp+

#

It’s basically a vpn that uses cloudflare servers 😂

pearl trail
delicate zephyr
#

in accordance with the ratelimits set

pearl trail
#

ah i see i see

hard wraith
#

Finally got my custom invite url to work so I dont need to rely on discord generated invite one anymore... tho it does force me to push the user to a configured application invite url to get the bot in the server... Not found away to add the bot to the servers automatically yet. I think its to protect from people abusing oauth access tokens of admins to add bots to servers without permissions etc.

prime cliff
#

A nice way to see the current changes when updating your docker container names/images/volumes/etc especially for longer ones 🙂

hard wraith
# ivory hawk Ooo custom url?

Ya, didn’t like how people could just add my bot and an important setting not be implemented. The custom invite url lets me get server owners to actually set it up before they use it.

ivory hawk
hard wraith
#

Ye

#

I’m putting the bot on topgg the second I’ve migrated the old terribly managed db off planet scale to my self hosted Postgres.

#

With a faster more durable schema and api 😂

hard wraith
#

I don’t like how little support and documentation there is for custom invite links tho… having to open the original discord invite link in a new tab (locking off guild select to show only the chosen guild) and check every 10s if the user has added the bot sucks for dx and ux. hopefully they release guilds.channels.read publicly soon and not just as a selection on the dev dashboard so I can configure important channels and roles before adding the bot.

elfin meadow
#

I am a WordPress and React Developer

ivory hawk
hard wraith
#

Stupid ts not knowing that user exists on type! Ugh I hate this sometimes.

hard wraith
#

Sometimes I regret being an on call devops engineer that also freelances... Then i remember I get to be outside in the warm and sun all day unless called into work or i decide to work on my projects... More developers should do this tbh

#

touching grass is nice

ivory hawk
hard wraith
frosty gale
hard wraith
#

But it is a lot of “whys this not working? Can you take a look and fix it?”

#

Love how most companies don’t actually use devops exactly as it’s defined… but it is development and operations.

lyric mountain
#

@solemn latch

solemn latch
#

Ty

hidden gorge
#

i took your advice and implemented it

delicate zephyr
#

password validation AND email validation btw

#

I can show you a perfect reason

#

and I fell for this issue

hidden gorge
hidden gorge
delicate zephyr
#

people trying to SQL inject

hidden gorge
#

oh...

delicate zephyr
#

hey word there

#

trying

hidden gorge
delicate zephyr
#

better than what I had

hidden gorge
delicate zephyr
#

❇️ nothing ❇️

hidden gorge
delicate zephyr
hidden gorge
delicate zephyr
#

I pushed with only frontend validation

#

someone found the api

#

and abused it

hidden gorge
#

also is it bad that my frontend and backend use the same validation functions?

prime cliff
#

MonkaS Not even email validation on the api tut tut luke

prime cliff
hidden gorge
#

ok im starting to think i broke the API

prime cliff
#

That should be a 400 bad request btw not internal error, if user input is invalid

hidden gorge
#

idk why its returning 500

prime cliff
hidden gorge
#

i think thats postman

#

OH THIS OVERRIDES IT

prime cliff
#

Yea but the error text is even wrong so something is FKED

delicate zephyr
#

its fine

#

I'll rewrite again soon

#

im a better dev now

hidden gorge
#

the server is getting data and validating it but apparently its not liking that

#

im now also realizing i have not yet coded it to hash the password during creation

prime cliff
#

Also is it intentional that people can set perms: { } like anyone with api access?

hidden gorge
prime cliff
#

With correct access checks right or only you?

sharp geyser
#

I dislike the idea of a json object for permissions

hidden gorge
prime cliff
#

Permissions? mmm never heard of that

hidden gorge
hidden gorge
sharp geyser
#

Me personally I would use bitflags

hidden gorge
#

fun time for me to learn something new

#

would you recommend easy-bits?

sharp geyser
#

Essentially it is an enum of

enum Permissions {
  READ = 0 << 1,
  WRITE = 0 << 2
}
hidden gorge
#

wait thats TS only shit

sharp geyser
#

Then you'd use bitwise operators to toggle permissions

sharp geyser
hidden gorge
#

this makes no sense to me

hidden gorge
sharp geyser
#

Who doesn't use ts in 2025

hidden gorge
neon leaf
hidden gorge
#

our website server is also js

wheat mesa
prime cliff
#

Wait bitflags are only in typescript whatthefuck

hidden gorge
hidden gorge
wheat mesa
#

VERIFIED is 0001, CONTRIBUTOR is 0010, supporter is 0100, and VIP is 1000

prime cliff
#

But why is it not in javascript itself 🙃

hidden gorge
#

should be

#

im still so confused on why fields is broken

sharp geyser
#

you just cant use enums

sharp geyser
hidden gorge
#

would you guys also know why the errors dont log?

#
global.logger.error("Error during user creation:", err);
sharp geyser
#

err is nothing

hidden gorge
#

lemme pull my logger

hidden gorge
# sharp geyser err is nothing
 } catch (err) {
        global.logger.error("Error during user creation:", err);
        return res.status(500).json({
            error: "Internal Server Error",
            details: err.message
        });
    }
sharp geyser
#

there is no actual error

hidden gorge
#

when i remove the log it logs the error tho...

neon leaf
#

or your logger doesnt accept 2 args

sharp geyser
#

or logger.error is filtering it

hidden gorge
#
class Logger {
    constructor(debugMode = false) {
        this.debugMode = debugMode;
    }

    formatMessage(level, color, message) {
        const timestamp = new Date().toISOString();
        console.log(`\x1b[1m\x1b[30m[${timestamp}] \x1b[${color}m[${level}]\x1b[0m`, message);
    }

    info(message) {
        this.formatMessage('INFO', '34', message);
    }

    warn(message) {
        this.formatMessage('WARN', '33', message);
    }

    error(message) {
        this.formatMessage('ERROR', '31', message);
    }

    debug(message) {
        if (this.debugMode) {
            this.formatMessage('DEBUG', '35', message);
        }
    }
}

module.exports = Logger;
``` i wonder
neon leaf
#

that doesnt accept multiple args

hidden gorge
#

ah

#

done

hidden gorge
sharp geyser
hidden gorge
#

OMG I HATE THIS CODE

#

also i learned using classes can be very useful

sharp geyser
#

yes

#

oop > *

queen needle
#

^

hidden gorge
neon leaf
#

everyone says yay oop but noone uses real oop

queen needle
#

java ahh

neon leaf
#

(real oop sucks)

hidden gorge
#
global.userAvatarBucket = new classes.r2Bucket("r2-user-cdn")
global.cdnBucket = new classes.r2Bucket("r2-bucket-emgkwc")
 const uploadResult = await global.userAvatarBucket.uploadAvatar(newFilePath, key);
 const fileUrl = global.userAvatarBucket.getAvatarUrl(key);

this is an example of my R2 Class

lyric mountain
#

did u mean 1 << n?

neon leaf
#

smh

hidden gorge
#

ykw i might as well just rewrite this in TS

neon leaf
#

rewrite it in rust 🚀🔥

hidden gorge
#

no

neon leaf
#

ok

hidden gorge
#

slight issue is

#

IDFK TS

sharp geyser
hidden gorge
#

confusing lang for me

neon leaf
sharp geyser
#

fuck no

queen needle
hidden gorge
#

also i take back any comments i made about hating github.

neon leaf
#

rewrite onedrive in rust 🚀

#

then problem solved

queen needle
#

Delete OneDrive from the face of the planet

neon leaf
#

good idea

#

let me write a rust program to do that rq

hidden gorge
neon leaf
#
use delete_all::delete_all;

fn main() {
  delete_all!("onedrive");
}
#

trust

queen needle
#

Hmm

#

Makes me think of the python Russian roulette meme

hidden gorge
#

also btw guys how do u make a .gitignore file?

neon leaf
#

pressing new

#

then naming it .gitignore

hidden gorge
#

oh

queen needle
#

Same way you make any other file

neon leaf
#

only problem with rust is that compile times are sloooow

queen needle
#

Just rewrite the compiler in rust ez

neon leaf
#

my api takes 14s on a 7900x3d

neon leaf
hidden gorge
#

is there not a .gitignore template for TS?

neon leaf
#

this is the life

hidden gorge
#

oh wait thats just node

#

i love this cmd now

queen needle
#

Life rust rewrite when

neon leaf
#

well switching to the mold linker did save 4s on each compile

#

sadly its written in c++

#

😠

#

my compile times could be caused by this but that would mean admitting having too many dependencies

queen needle
#

Bro has sha1 and 2

neon leaf
#

🙏

#

tbh I should just switch to only sha2

#

its literally faster than sha1 on my cpu

hidden gorge
#

also is ts or js faster or is it the same?

neon leaf
#

ts transpiles to js

#

so same speed

queen needle
#

Lame

neon leaf
#

just added transpiling time

hidden gorge
neon leaf
queen needle
#

Perfect

neon leaf
#

data -> md5 -> sha1 -> sha256 -> sha384 -> sha512

#

what do u think

queen needle
neon leaf
#

👎

queen needle
neon leaf
#

hmm true

#

very efficient way to store my etags

#

???????????????????????

blueprint-api_web  | 2025-04-11 22:41:01  INF  HTTP POST /api/telemetry (<censored ip>)```
#

im gonna call a priest

hidden gorge
#

im so confused

wheat mesa
#

Using express is 2025 is wild

neon leaf
#

🙏

hidden gorge
#

@wheat mesa

wheat mesa
#

I think fastify is the replacement

frosty gale
#

express is still very much maintained and very common in node (if you dont care too much about squeezing extra performance, then use fastify)

wheat mesa
#

Pretty sure it’s outdated in terms of features though, at least that’s what I heard the last time I used it

#

Better yet, don’t use js for an api backend

hidden gorge
queen needle
#

rust

#

I like using elixir for my backends

hidden gorge
#

plus i need a lang that supports the AWS SDK

queen needle
hidden gorge
#

oh

queen needle
#

i like C# is also a thing people commonly use for backend?

hidden gorge
#

bad idea

hidden gorge
#

(ive never used rust before)

prime cliff
queen needle
#

i was waiting for you

#

you were the one i thought of when i said that

#

ill have to look into it sometime

prime cliff
#

Have we met before or?

#

Ah i see from void bots

#

In 2021 dam

queen needle
#

i realized what I said was weird, I meant because you post about your projects which are in C#

hidden gorge
#

😭 3 versions of the API

prime cliff
#

Why is website all capitals xD

hidden gorge
#

i made the folder at like 2 AM

#

ok so is that bad

frosty gale
#
  • signed off by a person working for said company
#

windows server everywhere as well instead of an efficient linux system, drives me up the wall

hidden gorge
#

i already screwed up rust

#

oh nvm

prime cliff
#

Windows servers though are 🤢

#

They keep releasing new windows server version but their server gui is still stuck in 2010 with annoying colors and menus.

delicate zephyr
#

i'd rather install ubuntu and go through the pain of setting up remote desktop lmao

hidden gorge
#

i managed to get an http server working in rust

delicate zephyr
#

from a 2GB mem usage to 3MiB

#

fucking pog

prime cliff
#

2GB wtf

delicate zephyr
#

javascript

#

:^)

#

Just rewrote it in Go

hidden gorge
#

ok screw TcpListener

frosty gale
prime cliff
#

Oh god

frosty gale
#

if im ever making a company with lots of people i'll only run windows server for active directory on windows the rest will run on linux

#

sql server too every microsoft locked in company runs it instead of using something like mariadb or postgres

#

its not a bad database but its sort of the fact you have to pay for it when equivalent or even better alternatives exist for free?

delicate zephyr
#

bro golang shouldnt let me do this kekW

#

kinda nice that it does tho

#

fetcher is done

hidden gorge
#

ok this pisses me off i cannot find C++ Build tools in VS

prime cliff
#

With any framework it takes getting use to be it's not that hard to setup and the controller and service stuff is pretty nice

prime cliff
#

asp.net controller stuff is more formatted and parameter based being able to specify the headers, query and body instead of having to parse it yourself and also has support for asp.net authentication and asp.net identity if you want to go with account/oauth stuff

prime cliff
#

You can use VS/VSC or Rider

hidden gorge
prime cliff
sage bobcat
#

One message removed from a suspended account.

prime cliff
#

I personally use visual studio for all C# stuff, dracula dark theme and the intelisense is awesome

sage bobcat
#

One message removed from a suspended account.

prime cliff
#

If you also want to use C# blazor VS is the best with hot reload support

#

Intelisense is also great it will predict auto completion suggestions for you like if 2 models have the same names, frequent used auto completions based on your use and other stuff.

#

Bit like VSC auto complete but on steroids

wheat mesa
hidden gorge
wheat mesa
#

It’s not

hidden gorge
chrome dawn
#

Hello guys

wheat mesa
#

That goes with most applications though

quartz kindle
#

anyone good with tailwind stuff? how to fix this?

#

its a dropdown menu on mobile, which opens in fullscreen, but the padding is ew

#

how to make w-screen account for paddings and margins correctly?

sharp geyser
#

you can use breakpoints

#

m-0 md:m-4

sharp geyser
quartz kindle
#

so when i use w-screen it goes off-screen

sharp geyser
#

how does html look like

hidden gorge
quartz kindle
#

using daisyui

#

using w-max its not too bad

sharp geyser
#

I assume select is the hamburger menu or whatever

quartz kindle
#

role=button is the burger

#

the select is the language menu inside

sharp geyser
#

Ah that makes sense actually I’m stupid

quartz kindle
#

im just gonna leave it like this tbh

sharp geyser
#

I can only assume it has something to do with the parent div

#

Whatever dropdown applies

quartz kindle
#

yeah but w-full doesnt work

#

because the menu is probably using position absolute or something

wheat mesa
quartz kindle
wheat mesa
#

i have been proven wrong

hidden gorge
hidden gorge
hidden gorge
wheat mesa
#

as a power source sure, as a semiconductor, no

hidden gorge
wheat mesa
#

not feasibly, no

hidden gorge
wheat mesa
#

and how is that

quartz kindle
#

theoretically an rpi pico could be powered by less than 1000 potatoes

#

if im not mistaken

sharp geyser
#

You can do it on 1

#

If you use Idaho’s biggest potatoe

chrome dawn
#

@quartz kindle hello buddy

radiant kraken
#

top tier benchmarking

small tangle
#

📉 📈 📉 📈 📈

radiant kraken
#

how am i gonna explain this to my prof

neon leaf
#

not the best week

#

8.2k errors mmm

mortal snow
#

Quick question (I ain't super active here may try to be in the near-future)
if I wanted to have people test a bunch of stuff with a bot I own and then have them give me super genuine advice / feedback would that be something I can get from here?

sharp geyser
#

Possibly

#

I've seen some who offer to test things if they have spare time

warm carbon
neon leaf
#

yea

#

ran a db migration on prod too early

hidden gorge
#

do you guys think this is a good email verification? im still working on it

sharp geyser
#

Good enough

deft wolf
#

At first glance I didn't notice that there was white text on a white background

hidden gorge
sharp geyser
#

Oh neither did I

hidden gorge
#

also is using a noreply email good?

sharp geyser
#

why wouldn't it

hidden gorge
#

resend said to not use it

sharp geyser
#

bah

#

use what you want

#

noreply doesn't matter its quite literally what it's meant for

hidden gorge
#

o

prime cliff
#

Literally almost every major company uses noreply@ lmao where are you getting the description from

hidden gorge
#

is this a redundant amount of logging?

neon leaf
#

Yes

#

Personally I have like 5 lines on big apps

#

And 3 on small

#

Why even ASCII logo

vivid fulcrum
#

cause it looks cool

sharp geyser
#

ASCII = cool

vivid fulcrum
#

afaik even spring boot has an ascii splash logo

wheat mesa
#

You don’t need to log the versions of your packages when you already have a package.json that shows all of that

#

Looks like you spent more time on custom logging than you did making the actual API

deft wolf
#

✨ Fancy ✨

hidden gorge
hidden gorge
#

Rn I'm very focused on emails

hidden gorge
sharp geyser
#

Definitely is too much logging

#

you don't need to log every little thing

hidden gorge
sharp geyser
#

Redundant logs

hidden gorge
sharp geyser
#

Also not really needed tbh

sharp geyser
hidden gorge
sharp geyser
#

What I mean is that its redundant to state the same thing twice

hidden gorge
#

oops i forgot to remove the code emailing me

lyric mountain
hidden gorge
lyric mountain
#

like, output only info level and above to console by default

lyric mountain
#

I suppose this isn't very common outside java then

hidden gorge
lyric mountain
#

like, you have 5 levels - TRACE, DEBUG, INFO, WARN and ERROR

#

trace and debug would be the verbose stuff that's mostly irrelevant

wheat mesa
#

Personally, I hate adding logging throughout my program. It’s cluttering, I only add it if I’m debugging usually

lyric mountain
#

I like to keep 2 log files, one being a copypaste of console and one being debug level

#

console only gets info and above printed

hidden gorge
#

also should i compress my files when uploading them to our CDN?

#

because our one is already at 150 MB

vivid fulcrum
#

depends on what you're uploading 🤷‍♂️

hidden gorge
neon leaf
#

Images are already compressed

#

Id recommend converting to webp

hidden gorge
#

im gonna be working on image approval

vivid fulcrum
neon leaf
#

Yea

neon leaf
hidden gorge
#

tf happened there

sharp geyser
#

?

sharp geyser
#

Most people just dont know how to actually log

frosty gale
hard wraith
#

Makes devops so much nicer (somehow ad stuff is now covered under devops courses)

#

Azure ad is quite nice tbf because you can then do access control on servers and pipelines and stuff from ad… but it’s just… complicated as all things Microsoft are.

neon leaf
#

this laptop is older than me

hard wraith
#

I think I just threw up

neon leaf
hard wraith
#

I have nightmares about that bios

#

Is it xp or vista?

neon leaf
#

xp

hard wraith
#

Not so bad… prefer xp over vista

#

But damn… that bios is nightmare fuel.

#

Tho… the new thinkpads use the same bios just more modern so not that much better

sharp geyser
#

Can you dynamically change the redirect uri for discord's oauth system?

#

I want to return the user back to whatever page they were on last

#

Since I don't plan on having just 1 location be for linking discord to their account

neon leaf
#

you can attach state afaik

#

and just use that to redirect

sharp geyser
#

Oh right state

#

does that work for authorized_code grant or whatever

#

actually I dont think I can use state

vivid fulcrum
#

use cookies

#

state should work though

delicate zephyr
#

cookies works but you can use state

#

they get redirected to your oauth endpoint with the ?state= url param

sharp geyser
#

So i'd send a someauthorizeurl.com?state=wheretheycamefrom and then once they consent it goes back to my redirect uri with that state variable?

vivid fulcrum
#

exactly

sharp geyser
#

👍

#

Thanks guys

#

I was reading the docs and it was a bit confusing

#

💀

queen needle
#

Yeah I also used state for that, and put their current url

hidden gorge
#

so im still investigating the issue with fields, i logged the type and it returns Object

request Body:

{
    "username": "adminUser",
    "email": "admin@example.com",
    "profilePictureURL": "https://users.emgkwc.com/avatars/james.png",
    "password": "SuperSecure123!",
    "perms": {
        "editor": false,
        "developer": false,
        "owner": true
    }
}

my field Validation code:

       const {
            username,
            email,
            profilePictureURL,
            password,
            perms
        } = req.body;

        const userData = {
            username,
            email,
            profilePictureURL,
            password,
            perms,
            verificationProcess: {
                verified: false,
                currentCode: 0,
                codeExpiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000) 
            }
        };

        global.debugLogger.debug(`Typeof userData: ${typeof(userData)}`)

        if (typeof userData.perms === "string") {
            try {
                userData.perms = JSON.parse(
                    userData.perms.replace(/(\w+):/g, '"$1":')
                );
            } catch (e) {
                return res.status(400).json({ error: "Invalid perms format" });
            }
        }

        const missingFields = [];
        if (!userData.username) missingFields.push("username");
        if (!userData.email) missingFields.push("email");
        if (!userData.password) missingFields.push("password");

        if (missingFields.length > 0) {
            return res.status(400).json({
                error: "Missing required fields",
                missingFields
            });
        }
sharp geyser
#

Whats the issue

hidden gorge
#

oops didnt include my error

#

one second

hidden gorge
hidden gorge
lyric mountain
#

aight

hidden gorge
#

im just testing rn

#

but i have app.use(express.json()); in my main file

#

all my projects have body-parser and this one doesn't

lyric mountain
#

that json is invalid no?

hidden gorge
lyric mountain
#

it should be username: username

sharp geyser
#

not necessarily

#

Oh wait

#

yes necessarily

lyric mountain
#

yep lul

#

doesnt make sense that structure

sharp geyser
#

it won't know what it exactly is

#

userData is technically just a object of strings with one object at the end

#

you need to do what haku said

hidden gorge
#

first is the req.body second is the data filled out for the db

sharp geyser
#

Sure

lyric mountain
#

yes, but what IS userData

hidden gorge
sharp geyser
lyric mountain
#

no, it's a mangled json

sharp geyser
#

it has no keys

#

you are simply supplying a value for username, email, profile, etc etc

#

with the last member being a proper key/value pair

hidden gorge
#

huh???

hidden gorge
lyric mountain
#

yes

sharp geyser
#

yes that is what you need to do

hidden gorge
#

and guess what...

lyric mountain
#

it worked?

hidden gorge
sharp geyser
#

most likely

hidden gorge
#

nope

lyric mountain
#

hm

sharp geyser
#

How are you passing this to mongodb

#

because your error is at MongoDB.createUser

hidden gorge
#

i quit

sharp geyser
#

but you have not showed us this

hidden gorge
# sharp geyser but you have not showed us this

createUser is my custom function:

    /**
     * Inserts a new user into the users collection.
     * @param {object} userData - The user object.
     * @returns {object} - The inserted user document.
     */
    async createUser(userData) {
        try {
            const collection = this.db.collection("users");


            if (
                !userData.username ||
                !userData.email ||
                !userData.hashedPassword
            ) {
                throw new Error("Missing required fields: username, email, or password");
            }


            const user = {
                username: userData.username,
                email: userData.email,
                profilePictureURL: userData.profilePictureURL || "",
                hashedPassword: userData.hashedPassword,
                perms: userData.perms || {
                    editor: false,
                    developer: false,
                    owner: false
                }
            };


            Object.keys(user).forEach(key => {
                if (user[key] === undefined || user[key] === null) {
                    delete user[key];
                }
            });


            const existingUser = await collection.findOne({ email: user.email });
            if (existingUser) {
                throw new Error("User with this email already exists.");
            }


            const result = await collection.insertOne(user);
            global.logger.info(`User created with ID: ${result.insertedId}`);
            return result;

        } catch (error) {
            global.logger.error("Error creating user:", error);
            throw error;
        }
    }
sharp geyser
#

whatever you are passing into createUser is likely malformed

#

and missing key/values

hidden gorge
#

ofmg i just found it...

#

hashedPassword isnt a vaild thing bc i updated it to password...

sharp geyser
hidden gorge
#

bruh a new error now

sharp geyser
#

welcome to programming

#

new here?

hidden gorge
#

tf failed/??

sharp geyser
#

Thats where im out

#

mongodb is not my thing

#

What you are attempting to save/insert does not match the schema defined for that table

hidden gorge
#

hmm i see whats wrong

sharp geyser
#

Compare what you are doing vs what the mongodb schema expects

hidden gorge
#

i added data which doesnt exist in the collection

sharp geyser
#

bingo

hidden gorge
#

time to re run this command:

db.createCollection("users", {
    validator: {
        $jsonSchema: {
            bsonType: "object",
            required: ["username", "email", "password", "verificationProcess"],
            properties: {
                username: { bsonType: "string" },
                email: { bsonType: "string" },
                password: { bsonType: "string" },
                verificationProcess: {
                    bsonType: "object",
                    required: ["verified", "currentCode", "codeExpiresAt"],
                    properties: {
                        verified: { bsonType: "bool" },
                        currentCode: { bsonType: "int" },
                        codeExpiresAt: { bsonType: "date" }
                    }
                }
            }
        }
    }
});
sharp geyser
#

I am very worried for your practices

hidden gorge
#

oh i did this wrong again

sharp geyser
#

You tend to take the "break it down" approach

lament rock
# lyric mountain it should be `username: username`

This appeared at the top of my messages when I tabbed in. when not supplying a name like thing: value
the variable name of the value is used as the name, so what they wrote is valid.
{ username }
is the same thing as { username: username }

sharp geyser
#

Is it really?

lament rock
#

Yup

delicate zephyr
#

or any ORM honestly

sharp geyser
#

Interesting

hidden gorge
delicate zephyr
#

something that creates the schema for you

sharp geyser
#

Typeorm my beloved

delicate zephyr
sharp geyser
#

Nah

#

I just see prisma being recommended like 24/7 in here

delicate zephyr
#

I used TypeORM before, same with drizzle

sharp geyser
delicate zephyr
#

I just prefer Prisma

#

and from a getting started point, prisma is better

sharp geyser
#

I tried prisma, it was very much broken when I did

#

dk how it is now

delicate zephyr
#

6.6.0 is broken

lament rock
#

I wrote my own actually not shitty to me orm

delicate zephyr
#

6.5.0 isnt

sharp geyser
#

Oh lovely

delicate zephyr
delicate zephyr
hidden gorge
sharp geyser
#

I am shocked

#

Didnt know people other than tim still used js

lament rock
#

My main language is js

sharp geyser
#

I just hate js's allow everything approach

#

Ever since I've had a taste of enforced types

delicate zephyr
sharp geyser
#

I can't go back

lament rock
#

TypeScript my beloved

sharp geyser
#

When is drizzle going to be production ready

delicate zephyr
#

we use TypeScript and GoLang in topstats

sharp geyser
#

It's been like 3 years since I saw smth about drizzle

lament rock
#

even strict type checking with jsdoc is pretty cool (editor only)

sharp geyser
#

yea but then you have to write the jsdoc

#

and its tedious

delicate zephyr
#

you have to write TS too

#

:^)

sharp geyser
#

Yea but type safety is built into ts

delicate zephyr
#

I mean

sharp geyser
#

for the most part anyway

neon leaf
#

ive used it in many projects

#

its faster than prisma

delicate zephyr
#

TS literally compiles to JS :^) it's just doing typeof everywhere

sharp geyser
#

but I dont hvae to do it myself

#

😉

lament rock
sharp geyser
#

I use ts-ignore in a lot of places

neon leaf
#

i need to use it when making recursive types that parse strings

lament rock
#

Where is your type safety now

sharp geyser
#

Its there

#

I just turned it off for that one line

#

;)

lament rock
#

Thats unsafe

sharp geyser
#

So is using rust

#

but I still do it

delicate zephyr
#

but we're talking milliseconds

sharp geyser
#

those ms matter

neon leaf
#

ye

#

less than ms

sharp geyser
#

milliseconds matter too

neon leaf
#

when properly using prepared statements

delicate zephyr
neon leaf
#

bruh

sharp geyser
#

why drizzle so slow