45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
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(`${config.uwuzu.host}/api/ueuse/create`, {
|
||
method: "POST",
|
||
body: JSON.stringify({
|
||
token: config.uwuzu.apiToken,
|
||
text: `
|
||
${text}
|
||
|
||
このユーズはnoticeUwuzuの管理パネルから投稿されました
|
||
`,
|
||
nsfw: nsfw,
|
||
}),
|
||
});
|
||
|
||
const ueuseRes = await ueuseReq.json();
|
||
|
||
console.log(`ユーズ(管理パネル):${JSON.stringify(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;
|