Spaces:
Sleeping
Sleeping
Rename server1.js to server.js
Browse files- server1.js → server.js +13 -5
server1.js → server.js
RENAMED
|
@@ -47,11 +47,19 @@ async function extract(url, res){
|
|
| 47 |
app.get ('/extract',(req,res)=>extract(req.query.url,res));
|
| 48 |
app.post('/extract',(req,res)=>extract(req.body.url,res));
|
| 49 |
|
| 50 |
-
/*
|
| 51 |
-
app.post('/login', async (req,res)=>{
|
| 52 |
-
if (
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
});
|
| 56 |
|
| 57 |
console.log('🛰️ Public URL will be:', HOSTNAME);
|
|
|
|
| 47 |
app.get ('/extract',(req,res)=>extract(req.query.url,res));
|
| 48 |
app.post('/extract',(req,res)=>extract(req.body.url,res));
|
| 49 |
|
| 50 |
+
/* POST /login { "key": "secret" } */
|
| 51 |
+
app.post('/login', async (req, res) => {
|
| 52 |
+
/* if (TOKEN && req.body.key !== TOKEN)
|
| 53 |
+
return res.status(401).json({ error: 'unauthorized' });*/
|
| 54 |
+
|
| 55 |
+
// optional: debounce so two calls don't overlap
|
| 56 |
+
if (app.locals.running) return res.status(429).json({ error: 'busy' });
|
| 57 |
+
app.locals.running = true;
|
| 58 |
+
|
| 59 |
+
const result = await runLogin();
|
| 60 |
+
app.locals.running = false;
|
| 61 |
+
|
| 62 |
+
res.json(result);
|
| 63 |
});
|
| 64 |
|
| 65 |
console.log('🛰️ Public URL will be:', HOSTNAME);
|