Merge pull request #138 from Lapikud/development

Migrate to proxy, remove syslink
This commit is contained in:
2026-08-12 18:13:02 +03:00
committed by GitHub
4 changed files with 25 additions and 9 deletions

View File

@@ -26,10 +26,5 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: bun install run: bun install
- name: Ensure symlink to database before Drizzle migrations
run: |
rm -rf $GITHUB_WORKSPACE/data
ln -s ~/data $GITHUB_WORKSPACE/data
- name: Build project - name: Build project
run: bun --bun run build run: bun --bun run build

2
.nvmrc
View File

@@ -1 +1 @@
22 24.1.0

View File

@@ -2,5 +2,26 @@ import { drizzle } from "drizzle-orm/bun-sqlite";
import { Database } from "bun:sqlite"; import { Database } from "bun:sqlite";
import * as schema from "./schema/schema"; import * as schema from "./schema/schema";
let database: any = null;
function getDatabase() {
if (!database) {
const sqlite = new Database("data/tipilan.db"); const sqlite = new Database("data/tipilan.db");
export const db = drizzle(sqlite, { schema }); database = drizzle(sqlite, { schema });
}
return database;
}
export const db: any = new Proxy({}, {
get(_target, property, receiver) {
const instance = getDatabase() as unknown as Record<PropertyKey, unknown>;
const value = Reflect.get(instance, property, receiver);
if (typeof value === "function") {
return value.bind(instance);
}
return value;
},
});

View File

@@ -4,7 +4,7 @@ import { routing } from "./i18n/routing";
const handleI18nRouting = createMiddleware(routing); const handleI18nRouting = createMiddleware(routing);
export default function middleware(request: NextRequest) { export default function proxy(request: NextRequest) {
const response = handleI18nRouting(request); const response = handleI18nRouting(request);
const location = response.headers.get("location"); const location = response.headers.get("location");