blah express update

This commit is contained in:
newtbot 2023-12-19 19:24:50 +08:00
parent 7c53b362eb
commit 6fcf603603
3 changed files with 9 additions and 7 deletions

View File

@ -6,13 +6,13 @@
*/
const express = require("express");
const app = express();
const port = 3000;
const port = 80;
const testRoute = require("../routes/test.js")
const testRoute1 = require("../routes/latest-Data.js")
const latestDataroute = require("../routes/latest-Data.js")
app.use('/test', testRoute);
app.use('/api/latest-data', testRoute1);
app.use('/api/latest-data', latestDataroute);
app.listen(port, () => {

View File

@ -13,7 +13,7 @@ async function getLatestData() {
return latestData;
}
catch (error) {
console.error('Error:', error);
console.error(error);
return null;
}
}
@ -29,7 +29,7 @@ router.get('/', async (req, res) => {
res.status(200).send(data);
}
} catch (error) {
console.error('Error:', error);
console.error(error);
res.status(500).send('Internal Server Error');
}
});

View File

@ -12,8 +12,9 @@ async function getallData() {
return allData;
}
catch(error) {
console.error('Error:', error);
console.error(error);
return null;
}
}
@ -27,8 +28,9 @@ router.get('/', async (req, res) => {
res.send(data);
}
} catch (error) {
console.error('Error:', error);
console.error(error);
res.status(500).send('Internal Server Error');
}
});