import express from "express";
const CommandExecute = express.Router();

import Commands from "../../scripts/commands/main.js";

CommandExecute.post("/actions/command-execute", (req, res) => {
  try {
    (async () => {
      await Commands();
    })();

    res.status(202)
    .send("Accepted");
  } catch(err) {
    res.status(500)
    .send(`Error: ${err}`);
  }
});

CommandExecute.get("/actions/command-execute", (req, res) => {
  res.status(501)
  .send("POST Only");
});

export default CommandExecute;
