This commit is contained in:
2026-02-06 16:26:27 +09:00
parent b9919df00b
commit aa6667235a
2 changed files with 10 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import sqlite3 from 'sqlite3';
import cors from 'cors';
import { open } from 'sqlite';
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
@@ -21,7 +22,12 @@ app.use(express.json());
let db;
async function initializeDB() {
const dbPath = path.join(__dirname, 'wifi_markers.db');
const dbDir = path.join(__dirname, 'db');
if (!fs.existsSync(dbDir)) {
fs.mkdirSync(dbDir, { recursive: true });
}
const dbPath = path.join(dbDir, 'wifi_markers.db');
db = await open({
filename: dbPath,
driver: sqlite3.Database