feat: add Url Shortener (#895)

* WIP

* added prisma actions

* remove console.logs

* some more fixes

* tweaks

* addressed all PR review comments

* remove hits from the prisma schema and all its corresponding service logic

* add nanoid

* corrected placeholders

* change database model, bring shortUrl service up to Formbricks code conventions

* update UI and shortUrl endpoint to work with new service

---------

Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com>
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
This commit is contained in:
Subham Ray
2023-10-05 12:52:52 +05:30
committed by GitHub
parent 5f19ffabd1
commit ff39086d21
25 changed files with 377 additions and 39 deletions
@@ -0,0 +1,12 @@
-- CreateTable
CREATE TABLE "ShortUrl" (
"id" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
"url" TEXT NOT NULL,
CONSTRAINT "ShortUrl_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "ShortUrl_url_key" ON "ShortUrl"("url");
+7
View File
@@ -513,3 +513,10 @@ model User {
/// [UserNotificationSettings]
notificationSettings Json @default("{}")
}
model ShortUrl {
id String @id // generate nanoId in service
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
url String @unique
}