File size: 944 Bytes
5e9feb1
 
 
 
 
 
 
 
15702cf
5e9feb1
 
 
9bb3d3d
5e9feb1
 
 
 
 
 
 
 
 
 
 
9bb3d3d
 
 
 
5e9feb1
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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}`
        );
    });