v8.0.1
This commit is contained in:
parent
644ba912b1
commit
d20f630e1b
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "notice-uwuzu",
|
||||
"version": "v8.0@uwuzu1.6.1",
|
||||
"tag": "v8.0",
|
||||
"version": "v8.0.1@uwuzu1.6.1",
|
||||
"tag": "v8.0.1",
|
||||
"description": "Notice Bot for uwuzu",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -8,8 +8,7 @@ import CommandExecute from "./route/command.js";
|
|||
import ueusePost from "./route/ueuse.js";
|
||||
import WeatherUeuse from "./route/weather.js";
|
||||
import API from "./route/api.js";
|
||||
|
||||
AdminPanel();
|
||||
import Token from "./route/token.js";
|
||||
|
||||
export default async function AdminPanel() {
|
||||
// 無効
|
||||
|
@ -26,6 +25,7 @@ export default async function AdminPanel() {
|
|||
app.use(CommandExecute);
|
||||
app.use(WeatherUeuse);
|
||||
app.use(API);
|
||||
app.use(Token);
|
||||
app.use(express.static("panel/public"));
|
||||
|
||||
app.listen(port, () => {
|
||||
|
|
|
@ -57,6 +57,10 @@ document.getElementById("ueuse").addEventListener("click", async () => {
|
|||
});
|
||||
|
||||
document.getElementById("api").addEventListener("click", async () => {
|
||||
const token = await (fetch("/actions/token", {
|
||||
method: "GET",
|
||||
})).text();
|
||||
|
||||
const endpoint = prompt("エンドポイント", "/serverinfo-api").toLowerCase();
|
||||
|
||||
if (endpoint === "") {
|
||||
|
@ -64,7 +68,7 @@ document.getElementById("api").addEventListener("click", async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const body = prompt("body(JSON)", `{"key": "value"}`).toLowerCase();
|
||||
const body = prompt("body(JSON)", `{"token": ${token}}`).toLowerCase();
|
||||
|
||||
if (body === "") {
|
||||
alert("bodyが設定されていません。");
|
||||
|
|
|
@ -8,8 +8,7 @@ API.use(express.urlencoded({ extended: true }));
|
|||
|
||||
API.post("/actions/api", async (req, res, next) => {
|
||||
const endpoint = req.body.endpoint;
|
||||
let body = req.body.body
|
||||
body["token"] = config.uwuzu.apiToken;
|
||||
const body = req.body.body;
|
||||
|
||||
try {
|
||||
const apiReq = await fetch(`https://${config.uwuzu.host}/api${endpoint}`, {
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import express from "express";
|
||||
const Token = express.Router();
|
||||
|
||||
import config from "../../config.js";
|
||||
|
||||
Token.use(express.json());
|
||||
Token.use(express.urlencoded({ extended: true }));
|
||||
|
||||
Token.post("/actions/token", async (req, res, next) => {
|
||||
res.status(501)
|
||||
.send("GET Only");
|
||||
});
|
||||
|
||||
Token.get("/actions/token", (req, res) => {
|
||||
res.status(200)
|
||||
.send(config.uwuzu.apiToken);
|
||||
});
|
||||
|
||||
export default Token;
|
Loading…
Reference in New Issue