diff options
| -rw-r--r-- | docker-compose.yml | 12 | ||||
| -rw-r--r-- | package-lock.json | 20 | ||||
| -rw-r--r-- | package.json | 5 | ||||
| -rw-r--r-- | src/index.ts | 2 |
4 files changed, 37 insertions, 2 deletions
diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..177ab2b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' + +services: + api: + build: . + image: eu.gcr.io/slam-lang/slam-runner-api + environment: + PORT: 3000 + ports: + - 3000:3000 + volumes: + - ./src:/app/src diff --git a/package-lock.json b/package-lock.json index d00a134..30412f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@tinyhttp/app": "2.0.16", + "@tinyhttp/cors": "2.0.0", "@tinyhttp/logger": "1.3.0", "milliparsec": "2.2.1", "slam-types": "git://github.com/jantuomi/slam-types.git#a401431", @@ -256,6 +257,17 @@ "node": ">=12.4.0" } }, + "node_modules/@tinyhttp/cors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tinyhttp/cors/-/cors-2.0.0.tgz", + "integrity": "sha512-IwQsPBnK+gRrhTsPA4FPOfbNzZZt8cVsOIMNFb6HzoScaiWcoLEogL0Bz/aBSm8KM13uieVXoVT6udMqhqUS2A==", + "dependencies": { + "es-vary": "^0.1.1" + }, + "engines": { + "node": ">=12.4 || 14.x || >=16" + } + }, "node_modules/@tinyhttp/encode-url": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@tinyhttp/encode-url/-/encode-url-2.0.4.tgz", @@ -3423,6 +3435,14 @@ "resolved": "https://registry.npmjs.org/@tinyhttp/cookie-signature/-/cookie-signature-2.0.2.tgz", "integrity": "sha512-lyIdDzLILp6T2fymJn9zKBgXwlZMIUiqMUIEd4x/ZGFNvnNs/zeYDBQFdAygBtv4Bgl5Zpf6tN+e6fkj6TlMYQ==" }, + "@tinyhttp/cors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tinyhttp/cors/-/cors-2.0.0.tgz", + "integrity": "sha512-IwQsPBnK+gRrhTsPA4FPOfbNzZZt8cVsOIMNFb6HzoScaiWcoLEogL0Bz/aBSm8KM13uieVXoVT6udMqhqUS2A==", + "requires": { + "es-vary": "^0.1.1" + } + }, "@tinyhttp/encode-url": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@tinyhttp/encode-url/-/encode-url-2.0.4.tgz", diff --git a/package.json b/package.json index 56e87aa..44bafab 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,11 @@ "author": "", "license": "ISC", "dependencies": { - "slam-types": "git://github.com/jantuomi/slam-types.git#a401431", "@tinyhttp/app": "2.0.16", + "@tinyhttp/cors": "2.0.0", "@tinyhttp/logger": "1.3.0", "milliparsec": "2.2.1", + "slam-types": "git://github.com/jantuomi/slam-types.git#a401431", "tmp": "0.2.1", "tsm": "2.2.1" }, @@ -25,4 +26,4 @@ "eslint": "8.8.0", "nodemon": "2.0.15" } -}
\ No newline at end of file +} diff --git a/src/index.ts b/src/index.ts index 8e90fbe..a5128b3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ import { exec as cb_exec } from "child_process" import tmp from "tmp" import fs from "fs" import { RunnerApiSubmitRequest, RunnerApiSubmitResponse } from "slam-types" +import { cors } from "@tinyhttp/cors" const exec = promisify(cb_exec) const app = new App() @@ -28,6 +29,7 @@ app .use(logger({ timestamp: { format: "YYYY-MM-DDTHH:mm:ssZ" }, })) + .use(cors()) .use(json()) .post(RunnerApiSubmitRequest.path, async (req, res) => { const body: RunnerApiSubmitRequest.Body | undefined = req.body |
