41 lines
938 B
TypeScript
41 lines
938 B
TypeScript
import express from "express";
|
||
const ueusePost = express.Router();
|
||
|
||
import config from "../../config.js";
|
||
|
||
ueusePost.use(express.json());
|
||
ueusePost.use(express.urlencoded({ extended: true }));
|
||
|
||
ueusePost.post("/actions/ueuse", async (req, res, next) => {
|
||
const text = req.body.text;
|
||
const nsfw = req.body.nsfw;
|
||
|
||
try {
|
||
const ueuseReq = await fetch(`https://${config.uwuzu.host}/api/ueuse/create`, {
|
||
method: "POST",
|
||
body: JSON.stringify({
|
||
token: config.uwuzu.apiToken,
|
||
text: text,
|
||
nsfw: nsfw,
|
||
}),
|
||
});
|
||
|
||
const ueuseRes = await ueuseReq.json();
|
||
|
||
console.log(`ユーズ(管理パネル):${ueuseRes}`);
|
||
|
||
res.status(200)
|
||
.send("Success");
|
||
} catch(err) {
|
||
res.status(500)
|
||
.send(`Error: ${err}`);
|
||
}
|
||
});
|
||
|
||
ueusePost.get("/actions/ueuse", (req, res) => {
|
||
res.status(501)
|
||
.send("POST Only");
|
||
});
|
||
|
||
export default ueusePost;
|