Skip to content

About

Decoupled solution for link management with simple analytics

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Steps and overview

  1. I used Bun for this project not as a runtime but as a tool caller. Hence, bunx @nest/cli new
  2. Choose you package manager. I chose npm because it is tried and tested but also, because of this thing (This has so many issue referencings that I lost count)
  3. Immediately ditch the tsc compiler because the build times were attrocious. Use the new and shiny swc
{
  "$schema": "https://json.schemastore.org/nest-cli",
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "deleteOutDir": true,
    "builder": "swc"
  }
}
  1. And install it as bun add -d @swc/core @swc/cli
  2. Then, install the other dependencies. bun add drizzle-orm pg @nest/config @nestjs/passport passport passport-jwt
  3. Install the dev dependencies as: bun add -d drizzle-kit @types/pg @types/passport-jwt
  4. Set up your env file as explained in the example file.
  5. Create your schema to fit your needs. In my case it looks like this
  6. Create a globally accessible instance of the db for queries later.
  7. Create the DB module so that instances of DB can be imported to other modules.
  8. Install the most famour and probably tje most used package in NestJS. i.e bun add class-validator class-transformer
  9. Make your migrations and push to db. bunx drizzle-kit generate bunx drizzle-kit migrate bunx drizzle-kit push
  10. Register your DB module in the main application module.
  11. Finally create your auth module with auth service, controller and write your logic.

Note: For the rest you can consult the git logs

Note 2: Apparently Math.random() is so predictable that only 2 or 3 numbers maybe required to get the seed. And while the cycle for Math.random() , maybe high, I will be using this package called nanoid, which gives me unique URL-friendly strings and is lightweight(like 118 bytes, wtf)

Note 3: If you want to check out my PRNG implementations like vonNeumann Method and so on, check out: my PRNG repo

Note 4: It was pretty obvious from the get go that in account creation, the password hashing was going to give me trouble, and hence, I wll be switching to bcrypt and not use Bun's native "hasher" But it was worth a shot.

Big like concerning note:

I did not deploy this because this is not optimized for serverless and other providers who do non-serverless setups have either credit exhaustion restrictions(Railway) or cool down after short period of time(like 15 minutes)(Render), which does not suit my needs. And Vercel is serverless

About

Decoupled solution for link management with simple analytics

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages