import { policy } from "./common/access-control.ts"; import express from "express"; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; const argv: any = yargs(hideBin(process.argv)).parse(); import { sandBox } from "./sandBox.ts"; let port = argv.port || process.env.PORT || 7860; let app = express(); app.use(policy); app.post("/sandBox", express.text()); app.post("/sandBox", sandBox); app.use("/api/ping", express.json({ limit: "900kb" })); app.use("/api/ping", (req, res) => { res.status(200).json({ query: req.query, headers: req.rawHeaders, body: req.body, }); }); app.get("/", (req,res,next)=>{ res.status(200).send("Hello"); }); app .listen(port, () => { console.log( `starting at ${port} node ${process.version}` ); }) .on("error", function (err) { console.log( `failed to start at ${port} ${err}` ); });