Basic kysely setup

This commit is contained in:
Dominic Ferrando
2026-07-01 23:16:31 -04:00
parent ab6eb56814
commit 593db80067
6 changed files with 124 additions and 8 deletions
+7 -1
View File
@@ -11,7 +11,9 @@
"scripts": {
"dev": "bun run --hot src/index.ts",
"start": "bun run src/index.ts",
"build": "bun build --compile --minify-whitespace --minify-syntax --target bun-linux-x64 --outfile dist/server src/index.ts"
"build": "bun build --compile --minify-whitespace --minify-syntax --target bun-linux-x64 --outfile dist/server src/index.ts",
"db:codegen": "bunx kysely-codegen --env-file .env.development",
"db:seed": "bun run src/database/seed.ts"
},
"dependencies": {
"@blade-and-brawn/calculator": "workspace:*",
@@ -20,8 +22,12 @@
"@elysia/jwt": "^1.4.2",
"@elysia/server-timing": "^1.4.1",
"@elysiajs/cors": "^1.4.2",
"@types/pg": "^8.20.0",
"elysia": "^1.4.29",
"kysely": "^0.29.2",
"kysely-codegen": "^0.20.0",
"ml-levenberg-marquardt": "^5.0.1",
"pg": "^8.22.0",
"pino": "^10.3.1",
"zipcodes-us": "^1.1.3"
},
View File
+12
View File
@@ -0,0 +1,12 @@
import { Kysely, PostgresDialect } from 'kysely';
import { type DB } from 'kysely-codegen';
import { Pool } from "pg";
import { env } from '../env';
const db = new Kysely<DB>({
dialect: new PostgresDialect({
pool: new Pool({
connectionString: env.DATABASE_URL,
}),
})
});
+1
View File
@@ -19,6 +19,7 @@ export const env = {
WEBFLOW_WEBHOOK_SECRET: requireEnv("WEBFLOW_WEBHOOK_SECRET"),
AUTH_SECRET: requireEnv("AUTH_SECRET"),
ADMIN_PASSWORD: requireEnv("ADMIN_PASSWORD"),
DATABASE_URL: requireEnv("DATABASE_URL"),
NODE_ENV: optionEnv("NODE_ENV", "development"),
LOG_LEVEL: optionEnv("LOG_LEVEL", "info"),
};
-7
View File
@@ -25,13 +25,6 @@ import { env } from "./env";
import serverTiming from "@elysia/server-timing";
import jwt from "@elysia/jwt";
const log = pino({
level: env.LOG_LEVEL,
transport: env.NODE_ENV != "production"
? { target: "pino-pretty" }
: undefined,
});
// SERVICES
// -----------
const levelCalculator = new LevelCalculator(