This commit is contained in:
2026-04-06 00:33:27 +07:00
parent 0f7e386e2a
commit 9f4370365a
4 changed files with 32 additions and 27 deletions

View File

@@ -1,13 +1,17 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import jsonServer from 'json-server';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const server = jsonServer.create();
const router = jsonServer.router(path.join(import.meta.dir, 'db.json'));
const router = jsonServer.router(path.join(__dirname, 'db.json'));
// Serve static files từ folder public (images, etc.)
const middlewares = jsonServer.defaults({
logger: true,
static: path.join(import.meta.dir, 'public'),
static: path.join(__dirname, 'public'),
});
const port = process.env.PORT || 3100;