randydev commited on
Commit
41b05d6
·
verified ·
1 Parent(s): d97ef75

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +18 -0
index.js CHANGED
@@ -161,6 +161,24 @@ app.post('/webhook', (req, res) => {
161
  res.status(200).send('Webhook received');
162
  });
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  app.delete("/api/v1/delete-key", async (req, res) => {
165
  const dbClient = new Database("AkenoXJs");
166
  const collection = dbClient.collection("api_keys");
 
161
  res.status(200).send('Webhook received');
162
  });
163
 
164
+ app.delete("/api/v2/delete-key", async (req, res) => {
165
+ const apiKey = req.query.api_key;
166
+ if (!apiKey) {
167
+ return res.status(400).json({ error: "Missing 'api_key' parameter" });
168
+ }
169
+
170
+ try {
171
+ const DocsKey = await ApiKey.deleteOne({ key: apiKey });
172
+ if (DocsKey.deletedCount > 0) {
173
+ res.json({ message: "API key has been successfully deleted" });
174
+ } else {
175
+ res.status(404).json({ message: "API key not found" });
176
+ }
177
+ } catch (err) {
178
+ res.status(500).json({ error: `Key deletion failed: ${err.message}` });
179
+ }
180
+ });
181
+
182
  app.delete("/api/v1/delete-key", async (req, res) => {
183
  const dbClient = new Database("AkenoXJs");
184
  const collection = dbClient.collection("api_keys");