Update server.js

This commit is contained in:
Loi Phan
2024-01-13 21:05:40 +07:00
committed by GitHub
parent ddfb3342e2
commit 98309793dc
+7 -7
View File
@@ -4,15 +4,15 @@ const jsonServer = require('json-server')
const server = jsonServer.create()
// Uncomment to allow write operations
// const fs = require('fs')
// const path = require('path')
// const filePath = path.join('db.json')
// const data = fs.readFileSync(filePath, "utf-8");
// const db = JSON.parse(data);
// const router = jsonServer.router(db)
const fs = require('fs')
const path = require('path')
const filePath = path.join('db.json')
const data = fs.readFileSync(filePath, "utf-8");
const db = JSON.parse(data);
const router = jsonServer.router(db)
// Comment out to allow write operations
const router = jsonServer.router('db.json')
// const router = jsonServer.router('db.json')
const middlewares = jsonServer.defaults()