Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-strapi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 75252c23
authored
2024-06-17 15:18:42 +0530
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
delete api
1 parent
a298544b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
src/api/vendor/controllers/vendor.js
src/api/vendor/routes/custom-routes.js
src/api/vendor/controllers/vendor.js
View file @
75252c2
"use strict"
;
const
{
getService
}
=
require
(
"@strapi/plugin-users-permissions/server/utils"
);
const
fs
=
require
(
"fs"
);
/**
* vendor controller
...
...
@@ -47,14 +48,14 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
let
existingUser
;
existingUser
=
await
strapi
.
entityService
.
findMany
(
"api::vendor.vendor"
,
{
// fields: ["id"],
filters
:
{
phone
:
{
$eq
:
ctx
.
request
.
body
.
data
.
mobileNo
}
},
filters
:
{
phone
:
{
$eq
:
ctx
.
request
.
body
.
data
.
mobileNo
}
},
});
console
.
log
(
"existingUser> 1"
,
existingUser
);
if
(
!
existingUser
)
{
existingUser
=
await
strapi
.
entityService
.
findMany
(
"api::vendor.vendor"
,
{
// fields: ["id"],
filters
:
{
email
:
{
$eq
:
ctx
.
request
.
body
.
data
.
email
}
},
filters
:
{
email
:
{
$eq
:
ctx
.
request
.
body
.
data
.
email
}
},
});
}
console
.
log
(
"existingUser > 2"
,
existingUser
);
...
...
@@ -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!"
});
}
},
}));
src/api/vendor/routes/custom-routes.js
View file @
75252c2
...
...
@@ -16,6 +16,15 @@ const routes = {
// some configuration...
}
},
{
method
:
"POST"
,
path
:
"/vendor/removedirectory/delete"
,
handler
:
"api::vendor.vendor.removedirectory"
,
config
:
{
// some configuration...
}
}
],
};
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment