Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dist
.nvmrc

.env.sample
.env.local
.env

README.md

Expand Down
9 changes: 9 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NEXT_PUBLIC_ENV=dev
NEXT_PUBLIC_APP_NAME=sandbox-app

PORT=3000

# postgres connection string
DATABASE_CONNECTION_STRING=postgresql://postgres:password@localhost:5432/postgres

GITHUB_API_KEY=
12 changes: 0 additions & 12 deletions .envsample

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ node_modules
build
dist

.env.local
.env

.notes
19 changes: 19 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from "drizzle-kit";

import dotenv from "dotenv";

dotenv.config();

const connectionString = process.env.DATABASE_CONNECTION_STRING as string;

export default defineConfig({
out: "./migrations",
dialect: "postgresql",
schema: "./src/database/repositories/**.ts",
dbCredentials: {
url: connectionString,
},
migrations: {
prefix: "timestamp",
},
});
27 changes: 27 additions & 0 deletions migrations/20250828163143_overjoyed_prism.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
CREATE TYPE "public"."label" AS ENUM('MALWARE', 'PHISHING', 'ILLEGAL_CONTENT', 'ADULT_CONTENT', 'SPAM', 'HARASSMENT', 'HATE_SPEECH', 'SCAM', 'COPYRIGHT', 'MISLEADING', 'BROKEN_LINK', 'OTHER');--> statement-breakpoint
CREATE TABLE "keys" (
"id" serial PRIMARY KEY NOT NULL,
"uuid" varchar(36) NOT NULL,
"alias" text NOT NULL,
"url" text NOT NULL,
"is_secure" boolean DEFAULT false NOT NULL,
"redirect_url" text,
"expires_at" timestamp NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "keys_uuid_unique" UNIQUE("uuid"),
CONSTRAINT "keys_alias_unique" UNIQUE("alias"),
CONSTRAINT "keys_url_unique" UNIQUE("url"),
CONSTRAINT "keys_redirect_url_unique" UNIQUE("redirect_url")
);
--> statement-breakpoint
CREATE TABLE "reports" (
"id" serial PRIMARY KEY NOT NULL,
"uuid" varchar(36) NOT NULL,
"key_id" integer NOT NULL,
"label" varchar(36) NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "reports_uuid_unique" UNIQUE("uuid")
);
--> statement-breakpoint
ALTER TABLE "reports" ADD CONSTRAINT "reports_key_id_keys_id_fk" FOREIGN KEY ("key_id") REFERENCES "public"."keys"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "alias_idx" ON "keys" USING btree ("alias");
212 changes: 212 additions & 0 deletions migrations/meta/20250828163143_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
{
"id": "7c0ec2dc-9e9f-480e-bd9c-ba95ff419ef3",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.keys": {
"name": "keys",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "varchar(36)",
"primaryKey": false,
"notNull": true
},
"alias": {
"name": "alias",
"type": "text",
"primaryKey": false,
"notNull": true
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true
},
"is_secure": {
"name": "is_secure",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"redirect_url": {
"name": "redirect_url",
"type": "text",
"primaryKey": false,
"notNull": false
},
"expires_at": {
"name": "expires_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"alias_idx": {
"name": "alias_idx",
"columns": [
{
"expression": "alias",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"keys_uuid_unique": {
"name": "keys_uuid_unique",
"nullsNotDistinct": false,
"columns": [
"uuid"
]
},
"keys_alias_unique": {
"name": "keys_alias_unique",
"nullsNotDistinct": false,
"columns": [
"alias"
]
},
"keys_url_unique": {
"name": "keys_url_unique",
"nullsNotDistinct": false,
"columns": [
"url"
]
},
"keys_redirect_url_unique": {
"name": "keys_redirect_url_unique",
"nullsNotDistinct": false,
"columns": [
"redirect_url"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.reports": {
"name": "reports",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "varchar(36)",
"primaryKey": false,
"notNull": true
},
"key_id": {
"name": "key_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"label": {
"name": "label",
"type": "varchar(36)",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"reports_key_id_keys_id_fk": {
"name": "reports_key_id_keys_id_fk",
"tableFrom": "reports",
"tableTo": "keys",
"columnsFrom": [
"key_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"reports_uuid_unique": {
"name": "reports_uuid_unique",
"nullsNotDistinct": false,
"columns": [
"uuid"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {
"public.label": {
"name": "label",
"schema": "public",
"values": [
"MALWARE",
"PHISHING",
"ILLEGAL_CONTENT",
"ADULT_CONTENT",
"SPAM",
"HARASSMENT",
"HATE_SPEECH",
"SCAM",
"COPYRIGHT",
"MISLEADING",
"BROKEN_LINK",
"OTHER"
]
}
},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
13 changes: 13 additions & 0 deletions migrations/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1756398703976,
"tag": "20250828163143_overjoyed_prism",
"breakpoints": true
}
]
}
Loading