randydev commited on
Commit
7d62f05
·
verified ·
1 Parent(s): 7864014

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +3 -3
index.js CHANGED
@@ -75,17 +75,17 @@ app.use(express.static('public'));
75
 
76
  app.post('/generate-key', async (req, res) => {
77
  const dbClient = new Database("AkenoXJs", "FastJsAPI");
78
- const db = dbClient.collection()
79
  try {
80
  const newKey = myUUID;
81
- await db('apiKeys').insertOne({
82
  key: newKey,
83
  createdAt: new Date(),
84
  owner: '[email protected]'
85
  });
86
  res.json({ apiKey: newKey });
87
  } catch (err) {
88
- res.status(500).json({ error: `Key generation failed ${err.message}` });
89
  }
90
  });
91
 
 
75
 
76
  app.post('/generate-key', async (req, res) => {
77
  const dbClient = new Database("AkenoXJs", "FastJsAPI");
78
+ const collection = dbClient.collection('apiKeys'); // Specify collection name
79
  try {
80
  const newKey = myUUID;
81
+ await collection.insertOne({
82
  key: newKey,
83
  createdAt: new Date(),
84
  owner: '[email protected]'
85
  });
86
  res.json({ apiKey: newKey });
87
  } catch (err) {
88
+ res.status(500).json({ error: `Key generation failed: ${err.message}` });
89
  }
90
  });
91