50 lines
655 B
JavaScript
50 lines
655 B
JavaScript
|
|
/*
|
|
Imports
|
|
*/
|
|
import { runCommand } from "./minecraft";
|
|
const express = require('express')
|
|
require('dotenv').config()
|
|
|
|
|
|
/*
|
|
Constant declaration
|
|
*/
|
|
const app = express();
|
|
app.use(express.json())
|
|
|
|
const port = process.env.PORT || 3000;
|
|
|
|
|
|
/*
|
|
Socket.io socket function
|
|
*/
|
|
|
|
|
|
/*
|
|
Passport.js OAuth2/OICD handler
|
|
*/
|
|
|
|
|
|
/*
|
|
Express Routes
|
|
*/
|
|
app.post("/api/command", (req,res)=>{
|
|
const body = req.body;
|
|
|
|
if (!body["command"]) return res.sendStatus(400);
|
|
|
|
let commandResponse = runCommand(body["command"]);
|
|
|
|
res.send({
|
|
response: commandResponse
|
|
})
|
|
})
|
|
|
|
|
|
/*
|
|
Run Express
|
|
*/
|
|
app.listen(() => {
|
|
console.log("Running Server!")
|
|
}, port) |