i hyperfocused and here is v1
This commit is contained in:
parent
8f43e6a6a9
commit
4090fd621e
34 changed files with 4135 additions and 22 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"lineWidth": 256,
|
||||
"lineWidth": 72,
|
||||
"indentStyle": "space",
|
||||
"formatWithErrors": true,
|
||||
"indentWidth": 2
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"allowImportingTsExtensions": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"alwaysStrict": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"esModuleInterop": true,
|
||||
"importHelpers": false,
|
||||
"incremental": true,
|
||||
"lib": ["esnext"],
|
||||
"module": "Node16",
|
||||
"moduleResolution": "Node16",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"newLine": "lf",
|
||||
"noEmit": true,
|
||||
"noEmitHelpers": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
|
|
@ -22,7 +23,7 @@
|
|||
"resolveJsonModule": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"target": "ES2020",
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
packages/database/biome.json
Normal file
4
packages/database/biome.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
|
||||
"extends": ["@datamine/config/biome"]
|
||||
}
|
||||
6
packages/database/drizzle.config.ts
Normal file
6
packages/database/drizzle.config.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import type { Config } from "drizzle-kit";
|
||||
|
||||
export default {
|
||||
schema: "./src/schema.ts",
|
||||
out: "./migrations",
|
||||
} satisfies Config;
|
||||
34
packages/database/package.json
Normal file
34
packages/database/package.json
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "@datamine/database",
|
||||
"packageManager": "yarn@4.1.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./dist/main.js",
|
||||
"module": "./dist/main.js",
|
||||
"types": "./dist/main.d.ts",
|
||||
"exports": {
|
||||
"import": {
|
||||
"types": "./dist/main.d.ts",
|
||||
"default": "./dist/main.js"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.6.4",
|
||||
"@datamine/config": "workspace:*",
|
||||
"@types/node": "20.12.7",
|
||||
"pkgroll": "2.0.2",
|
||||
"tsx": "4.7.2",
|
||||
"typescript": "5.4.5"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "biome check ./src/**/*",
|
||||
"build": "pkgroll",
|
||||
"drizzle": "drizzle-kit generate:pg"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/pg": "8.11.5",
|
||||
"drizzle-kit": "0.20.14",
|
||||
"drizzle-orm": "0.30.8",
|
||||
"pg": "8.11.5"
|
||||
}
|
||||
}
|
||||
23
packages/database/src/main.ts
Normal file
23
packages/database/src/main.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||||
import { resolve } from "node:path";
|
||||
import pg from "pg";
|
||||
import * as schema from "./schema.ts";
|
||||
|
||||
const client = new pg.Client({
|
||||
host: process.env.DB_HOST,
|
||||
port: Number(process.env.DB_PORT),
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
export const database = drizzle(client, { schema });
|
||||
await migrate(database, {
|
||||
migrationsFolder: resolve(import.meta.dirname, "../migrations"),
|
||||
});
|
||||
|
||||
export * as Drizzle from "drizzle-orm";
|
||||
export * as Schema from "./schema.ts";
|
||||
10
packages/database/src/schema.ts
Normal file
10
packages/database/src/schema.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { bigint, pgTable } from "drizzle-orm/pg-core";
|
||||
|
||||
export const servers = pgTable("servers", {
|
||||
id: bigint("id", { mode: "bigint" }).primaryKey(),
|
||||
channel: bigint("channel", { mode: "bigint" }).notNull(),
|
||||
role: bigint("role", { mode: "bigint" }),
|
||||
});
|
||||
|
||||
export type Server = typeof servers.$inferSelect;
|
||||
export type NewServer = typeof servers.$inferInsert;
|
||||
5
packages/database/tsconfig.json
Normal file
5
packages/database/tsconfig.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"extends": "@datamine/config/typescript",
|
||||
"exclude": ["node_modules"],
|
||||
"include": ["src"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue