Update index.js
Browse files
index.js
CHANGED
@@ -81,7 +81,25 @@ app.use(
|
|
81 |
|
82 |
app.use(express.static('public'));
|
83 |
|
84 |
-
app.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
const dbClient = new Database("AkenoXJs", "FastJsAPI");
|
86 |
const collection = dbClient.collection('api_keys');
|
87 |
try {
|
|
|
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');
|
87 |
+
const apiKey = req.query.api_key;
|
88 |
+
try {
|
89 |
+
DocsKey = await collection.findOne({key: apiKey})
|
90 |
+
if (DocsKey) {
|
91 |
+
let owner = DocsKey.owner;
|
92 |
+
let createdAt = DocsKey.createdAt;
|
93 |
+
res.json({ owner: owner, createdAt: createdAt });
|
94 |
+
} else {
|
95 |
+
res.json({ message: "nothing found" });
|
96 |
+
}
|
97 |
+
} catch (err) {
|
98 |
+
res.status(500).json({ error: `Key failed: ${err.message}` });
|
99 |
+
}
|
100 |
+
});
|
101 |
+
|
102 |
+
app.post('/v1/generate-key', async (req, res) => {
|
103 |
const dbClient = new Database("AkenoXJs", "FastJsAPI");
|
104 |
const collection = dbClient.collection('api_keys');
|
105 |
try {
|