From bbf1f031d00b99ac0290fb8bd028ee3aa7a141d8 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Wed, 17 Nov 2021 18:02:58 +0100 Subject: [PATCH] initial commit --- .gitignore | 1 + README.md | 5 +++++ build-server-crystal.cr | 18 ++++++++++++++++++ shard.lock | 22 ++++++++++++++++++++++ shard.yml | 8 ++++++++ test/strategy | 3 +++ 6 files changed, 57 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 build-server-crystal.cr create mode 100644 shard.lock create mode 100644 shard.yml create mode 100755 test/strategy diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a65b417 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lib diff --git a/README.md b/README.md new file mode 100644 index 0000000..02b0fd2 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +```sh +shard install +STRATEGIES_DIR=test crystal build-server-crystal.cr --port 4000 +curl -X POST "localhost:4000/strategy?file=build-server-crystal.cr" -H "Content-Type: application/json" --data '{"a":1}' +``` diff --git a/build-server-crystal.cr b/build-server-crystal.cr new file mode 100644 index 0000000..7dab735 --- /dev/null +++ b/build-server-crystal.cr @@ -0,0 +1,18 @@ +require "kemal" + +strategies_dir = ENV.fetch("STRATEGIES_DIR") + +post "/:strategy" do |env| + stdout = IO::Memory.new + Process.run( + "#{strategies_dir}/#{env.params.url["strategy"]}", + [ + env.params.query.to_h.to_json, + env.params.json.to_json + ], + output: stdout, + ) + stdout.to_s +end + +Kemal.run diff --git a/shard.lock b/shard.lock new file mode 100644 index 0000000..499152c --- /dev/null +++ b/shard.lock @@ -0,0 +1,22 @@ +version: 2.0 +shards: + backtracer: + git: https://github.com/sija/backtracer.cr.git + version: 1.2.1 + + exception_page: + git: https://github.com/crystal-loot/exception_page.git + version: 0.2.0 + + kemal: + git: https://github.com/kemalcr/kemal.git + version: 1.1.0 + + kilt: + git: https://github.com/jeromegn/kilt.git + version: 0.6.1 + + radix: + git: https://github.com/luislavena/radix.git + version: 0.4.1 + diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..d5d6b4c --- /dev/null +++ b/shard.yml @@ -0,0 +1,8 @@ +name: build-server-crystal +version: 0.1.0 + +dependencies: + kemal: + github: kemalcr/kemal + +license: MIT diff --git a/test/strategy b/test/strategy new file mode 100755 index 0000000..afe606b --- /dev/null +++ b/test/strategy @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +echo "hello world!"