AXCWG 3 місяців тому
батько
коміт
395a32b294
2 змінених файлів з 13 додано та 2 видалено
  1. 1 0
      UserInteractions.js
  2. 12 2
      main.js

+ 1 - 0
UserInteractions.js

@@ -38,6 +38,7 @@ export default function UserInteractions(opts) {
     app.options("/*", (req, res) => {
         res.set(cwh).end("FUCK YOU CORS")
     })
+
     app.get("/userapi", (req, res) => {
         if (!req.session.uuid) {
             res.set(cwh).status(500).json({code: 500, R: "IO"})

+ 12 - 2
main.js

@@ -27,8 +27,8 @@ const Kind = {
 
 
 const db = mysql.createConnection({
-    host: 'localhost',
-    user: 'root',
+    host: 'andyxie.cn',
+    user: 'external',
     password: 'moyingren2015',
     database: "instrunet_data",
     pool: pool,
@@ -54,6 +54,7 @@ import nrc from "node-run-cmd";
 import bodyParser from "body-parser";
 
 import UserInteractions from "./UserInteractions.js";
+import cwh from "./Singletons.js";
 
 webp.grant_permission()
 let queue = new Queue();
@@ -550,6 +551,15 @@ setInterval(() => {
     })
 }, 10000)
 
+app.get("/avatar", async (req, res) => {
+    if(!req.query.uuid){
+        res.set(cwh).status(500).json({code: 500, R: "IO"})
+        return
+    }
+    db.execute("SELECT avatar from user where uuid = ?", [req.query.uuid], (err, result) => {
+        res.set(cwh).end(result[0].avatar);
+    })
+})
 // Fetch
 app.get('/:uuid', async function (req, res) {