mirror of
https://github.com/Lapikud/tipilan.git
synced 2026-09-22 15:22:59 +00:00
Merge pull request #138 from Lapikud/development
Migrate to proxy, remove syslink
This commit is contained in:
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@@ -26,10 +26,5 @@ jobs:
|
||||
- name: Install dependencies
|
||||
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
|
||||
run: bun --bun run build
|
||||
|
||||
@@ -2,5 +2,26 @@ import { drizzle } from "drizzle-orm/bun-sqlite";
|
||||
import { Database } from "bun:sqlite";
|
||||
import * as schema from "./schema/schema";
|
||||
|
||||
const sqlite = new Database("data/tipilan.db");
|
||||
export const db = drizzle(sqlite, { schema });
|
||||
let database: any = null;
|
||||
|
||||
function getDatabase() {
|
||||
if (!database) {
|
||||
const sqlite = new Database("data/tipilan.db");
|
||||
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;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import { routing } from "./i18n/routing";
|
||||
|
||||
const handleI18nRouting = createMiddleware(routing);
|
||||
|
||||
export default function middleware(request: NextRequest) {
|
||||
export default function proxy(request: NextRequest) {
|
||||
const response = handleI18nRouting(request);
|
||||
|
||||
const location = response.headers.get("location");
|
||||
Reference in New Issue
Block a user