Update index.js
Browse files
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
|
79 |
try {
|
80 |
const newKey = myUUID;
|
81 |
-
await
|
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 |
|