Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.
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
1 change: 1 addition & 0 deletions packages/database/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DB_URL=
1 change: 1 addition & 0 deletions packages/database/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
12 changes: 12 additions & 0 deletions packages/database/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./src/schema.ts",
out: "./drizzle",
dialect: "postgresql",
dbCredentials: {
url: process.env.DB_URL as string,
},
verbose: true,
strict: true,
});
18 changes: 18 additions & 0 deletions packages/database/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "database",
"version": "1.0.0",
"description": "",
"main": "./src/index.ts",
"types": "./src/index.ts",
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"drizzle-orm": "^0.31.0",
"postgres": "^3.4.4"
},
"devDependencies": {
"@types/node": "^20.13.0",
"drizzle-kit": "^0.22.1"
}
}
8 changes: 8 additions & 0 deletions packages/database/src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import postgres from "postgres";
import { drizzle } from "drizzle-orm/postgres-js";

import * as schema from "./schema";

const queryClient = postgres(process.env.DB_URL as string);

export const database = drizzle(queryClient, { schema });
5 changes: 5 additions & 0 deletions packages/database/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { database } from "./client";

export * as schema from "./schema";

export const db = database;
6 changes: 6 additions & 0 deletions packages/database/src/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { pgTable, text, uuid } from "drizzle-orm/pg-core";

export const users = pgTable("users", {
id: uuid("id").primaryKey(),
fullName: text("full_name"),
});
15 changes: 15 additions & 0 deletions packages/database/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"moduleResolution": "node",
"preserveWatchOutput": true,
"skipLibCheck": true,
"noEmit": true,
"strict": true
},
"exclude": [
"node_modules"
]
}
Loading