1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const express_1 = require("express");
|
7 | const router = express_1.Router();
|
8 | const DockerCompiler_1 = __importDefault(require("./DockerCompiler"));
|
9 | const CachingUrlFetcher_1 = __importDefault(require("./CachingUrlFetcher"));
|
10 | const compiler = new DockerCompiler_1.default(new CachingUrlFetcher_1.default());
|
11 | router.use(express_1.json());
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | function run(method) {
|
17 | return async (req, res) => {
|
18 | try {
|
19 |
|
20 | const node = await compiler[method](req.body);
|
21 | res.status(200).json(node);
|
22 | }
|
23 | catch (error) {
|
24 | res.status(500).write(error.stack);
|
25 | }
|
26 | };
|
27 | }
|
28 | router.put('/compile', run('compile'));
|
29 | router.put('/compile', run('execute'));
|
30 | exports.default = router;
|