mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
Minor
This commit is contained in:
@@ -6,6 +6,8 @@ const server = jsonServer.create();
|
|||||||
const router = jsonServer.router("./src/mocks/db.json");
|
const router = jsonServer.router("./src/mocks/db.json");
|
||||||
const middlewares = jsonServer.defaults();
|
const middlewares = jsonServer.defaults();
|
||||||
|
|
||||||
|
const localStorage = [];
|
||||||
|
|
||||||
server.use(middlewares);
|
server.use(middlewares);
|
||||||
|
|
||||||
server.use((req, res, next) => {
|
server.use((req, res, next) => {
|
||||||
@@ -14,7 +16,7 @@ server.use((req, res, next) => {
|
|||||||
req.method = "DELETE";
|
req.method = "DELETE";
|
||||||
} else if (req.url === "/upload") {
|
} else if (req.url === "/upload") {
|
||||||
const taskId = uuid();
|
const taskId = uuid();
|
||||||
localStorage.setItem(taskId, true);
|
localStorage.push(taskId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
@@ -27,7 +29,7 @@ router.render = (req, res) => {
|
|||||||
res.status(200).jsonp({ status: "ok" });
|
res.status(200).jsonp({ status: "ok" });
|
||||||
} else if (req.url.includes("/task_status")) {
|
} else if (req.url.includes("/task_status")) {
|
||||||
const taskId = req.query["task_id"];
|
const taskId = req.query["task_id"];
|
||||||
const taskIdExists = localStorage.getItem(taskId);
|
const taskIdExists = localStorage.includes(taskId);
|
||||||
if (taskIdExists) {
|
if (taskIdExists) {
|
||||||
res.status(200).jsonp({
|
res.status(200).jsonp({
|
||||||
result: {
|
result: {
|
||||||
@@ -40,7 +42,7 @@ router.render = (req, res) => {
|
|||||||
status: "SUCCESS",
|
status: "SUCCESS",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.status(404);
|
res.status(404).jsonp({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user