fix: 本地开发支持 DB_DRIVER=sqlite 零依赖启动(test2 PG 不可达时后端启动即崩)
This commit is contained in:
1 parent
c05339e21c
commit
0deabfed45
2 files changed
+13
-2
No files matched your search
@@ -82,7 +82,15 @@ export function createApp(db?: Db): Express {
|
||||
const isMain = process.argv[1] !== undefined && process.argv[1]!.endsWith("server.ts");
|
||||
if (isMain) {
|
||||
void (async (): Promise<void> => {
|
||||
await initDatabase();
|
||||
// DB_DRIVER=sqlite → 本地零依赖文件库(data/perler-lab.db,可用 DB_PATH 覆盖路径)。
|
||||
// 办公网连不上 test2 PostgreSQL(DEFAULT_DATABASE_URL 超时)时也能本地开发;
|
||||
// 缺省仍走 PostgreSQL(DATABASE_URL / DEFAULT_DATABASE_URL),测试/生产不受影响。
|
||||
if (process.env["DB_DRIVER"] === "sqlite") {
|
||||
const dbPath = process.env["DB_PATH"];
|
||||
initDatabase(dbPath === undefined ? {} : { dbPath });
|
||||
} else {
|
||||
await initDatabase();
|
||||
}
|
||||
createApp().listen(PORT, () => {
|
||||
console.log(`PERLER LAB server running on http://localhost:${PORT}`);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user