Mock upload call

This commit is contained in:
Akshay
2023-10-08 21:40:17 +05:30
parent 01457bbe79
commit ff1362e462
3 changed files with 20 additions and 2 deletions

View File

@@ -9,7 +9,8 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"json-server": "^0.17.4"
"json-server": "^0.17.4",
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/json-server": "^0.14.5"
@@ -1226,6 +1227,18 @@
"node": ">= 0.4.0"
}
},
"node_modules/uuid": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",

View File

@@ -12,7 +12,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"json-server": "^0.17.4"
"json-server": "^0.17.4",
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/json-server": "^0.14.5"

View File

@@ -1,5 +1,6 @@
import jsonServer from "json-server";
import routes from "./mocks/routes.json" assert { type: "json" };
import { v4 as uuid } from "uuid";
const server = jsonServer.create();
const router = jsonServer.router("./src/mocks/db.json");
@@ -11,6 +12,9 @@ server.use((req, res, next) => {
if (req.method === "POST") {
if (req.url.includes("/delete_conversation")) {
req.method = "DELETE";
} else if (req.url === "/upload") {
const taskId = uuid();
localStorage.setItem(taskId, true);
}
}
next();