mirror of
https://dev.s-ul.net/Galexion/MaiMaiDXNet.git
synced 2024-12-18 07:45:54 +01:00
90 lines
2.6 KiB
JavaScript
90 lines
2.6 KiB
JavaScript
var express = require('express');
|
|
var router = express.Router();
|
|
var fetch = require('cross-fetch');
|
|
const fs = require('fs')
|
|
var config = require('../config.json');
|
|
var {getExtId,getUserArea,getUserScores,getUserUnbanned,getUserBanned, getUserData} = require("../dbhandler.js");
|
|
|
|
router.post('/getExtId/', function (req, res, next) {
|
|
getExtId(req).then(
|
|
(mUser) => {
|
|
res.status(200).json({ data: mUser, status: "Complete" });
|
|
},
|
|
(reason) => {
|
|
res.status(500).json({ error: reason, status: "Failed" });
|
|
console.error(reason); // Error!
|
|
},
|
|
);
|
|
});
|
|
|
|
router.post('/getUserData/', function (req,res,next) {
|
|
getUserData(req).then(
|
|
(mUser) => {
|
|
res.status(200).json({ data: mUser, status: "Complete" });
|
|
},
|
|
(reason) => {
|
|
res.status(500).json({ error: reason, status: "Failed" });
|
|
console.error(reason); // Error!
|
|
},
|
|
);
|
|
})
|
|
|
|
router.post('/getUserScores/', function (req,res,next) {
|
|
getUserScores(req).then(
|
|
(mUser) => {
|
|
res.status(200).json({ data: mUser, status: "Complete" });
|
|
},
|
|
(reason) => {
|
|
res.status(500).json({ error: err.message, status: "Failed" });
|
|
console.error(reason); // Error!
|
|
},
|
|
);
|
|
});
|
|
|
|
router.post('/getUserArea/', function (req,res,next) {
|
|
getUserArea(req).then(
|
|
(mUser) => {
|
|
res.status(200).json({ data: mUser, status: "Complete" });
|
|
},
|
|
(reason) => {
|
|
res.status(500).json({ error: err.message, status: "Failed" });
|
|
console.error(reason); // Error!
|
|
},
|
|
);
|
|
});
|
|
|
|
router.post('/getuserbanned/', function (req,res,next) {
|
|
getUserBanned(req).then(
|
|
(result) => {
|
|
res.send(result);
|
|
},
|
|
(reason) => {
|
|
res.status(500).send(reason);
|
|
console.error(reason); // Error!
|
|
},
|
|
);
|
|
});
|
|
|
|
router.post('/getuserunbanned/', function (req,res,next) {
|
|
getUserUnbanned(req).then(
|
|
(result) => {
|
|
res.send(result);
|
|
},
|
|
(reason) => {
|
|
res.status(500).send(reason);
|
|
console.error(reason); // Error!
|
|
},
|
|
);
|
|
});
|
|
|
|
router.get('/getmemorialimagelist/', function (req,res,next) {
|
|
let ext = ".jpg";
|
|
// Use fs.readdirSync() to get the file names synchronously
|
|
const files = fs.readdirSync(config.DXMemorialImageDirectory);
|
|
// Filter the files by extension and create an array of names
|
|
const imageNames = files.filter(file => file.endsWith(ext)).map(file => file.slice(0, -ext.length));
|
|
// Create and return a JSON object with the image names
|
|
res.send(imageNames);
|
|
});
|
|
|
|
module.exports = router; |