randydev commited on
Commit
be1f5f7
·
verified ·
1 Parent(s): 98b22d2

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +16 -0
index.js CHANGED
@@ -81,6 +81,22 @@ app.use(
81
 
82
  app.use(express.static('public'));
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  app.get("/v1/show-key", async (req, res) => {
85
  const dbClient = new Database("AkenoXJs", "FastJsAPI");
86
  const collection = dbClient.collection('api_keys');
 
81
 
82
  app.use(express.static('public'));
83
 
84
+ app.delete("/v1/delete-key", async (req, res) => {
85
+ const dbClient = new Database("AkenoXJs", "FastJsAPI");
86
+ const collection = dbClient.collection('api_keys');
87
+ const apiKey = req.query.api_key;
88
+ try {
89
+ const DocsKey = await collection.deleteOne({key: apiKey})
90
+ if (DocsKey) {
91
+ res.json({ message: "has been successfully deleted "});
92
+ } else {
93
+ res.json({ message: "nothing found" });
94
+ }
95
+ } catch (err) {
96
+ res.status(500).json({ error: `Key failed: ${err.message}` });
97
+ }
98
+ });
99
+
100
  app.get("/v1/show-key", async (req, res) => {
101
  const dbClient = new Database("AkenoXJs", "FastJsAPI");
102
  const collection = dbClient.collection('api_keys');