diff --git a/javascript/hello-world-js/README.md b/javascript/hello-world-js/README.md new file mode 100644 index 0000000..9b12458 --- /dev/null +++ b/javascript/hello-world-js/README.md @@ -0,0 +1,35 @@ +# Hello world js + +Simple sequence that outputs "Hello world" written in javascript. + +## Running + +> ❗ Remember to [setup transform-hub locally](https://docs.scramjet.org/platform/self-hosted-installation) or use the [platform's environment](https://docs.scramjet.org/platform/quick-start) for the sequence deployment. + +Open two terminals and run the following commands: + +**The first terminal:** + +```bash +# go to 'hello-world-js' directory +cd javascript/hello-world-js + +# install node_modules +npm install + +# go back to javascript/ directory +cd ../ + +# deploy 'hello-world-js' Sequence +si seq deploy hello-world-js +``` + +**The second terminal** + +Read the Instance output: + +```bash +si inst output - +``` + +You should see "Hello World!" printed out in the terminal. diff --git a/javascript/hello-world-js/index.js b/javascript/hello-world-js/index.js new file mode 100644 index 0000000..962b1be --- /dev/null +++ b/javascript/hello-world-js/index.js @@ -0,0 +1,12 @@ +const { PassThrough } = require("stream"); + +module.exports = async function(_input) { + // create a clean output stream + const out = new PassThrough({ encoding: "utf-8" }); + + // write some data to the output stream + out.write("Hello World!"); + + // return the output stream so it can be consumed (e.g. by CLI client) + return out; +}; diff --git a/javascript/hello-world-js/package.json b/javascript/hello-world-js/package.json new file mode 100644 index 0000000..d26a3d4 --- /dev/null +++ b/javascript/hello-world-js/package.json @@ -0,0 +1,26 @@ +{ + "name": "@scramjet/hello-world-js", + "version": "0.0.1", + "main": "index.js", + "author": "a-tylenda", + "license": "GPL-3.0", + "description": "Simple Sequence that prints out 'Hello World!' to the Instance output.", + "keywords": [ + "sample", + "easy", + "streaming", + "Data Producer" + ], + "repository": { + "type": "git", + "url": "https://github.com/scramjetorg/platform-samples/tree/main/javascript/hello-world-js" + }, + "scripts": { + "build": "mkdir -p dist/ && cp -r index.js package.json dist/ && (cd dist && npm i --omit=dev)", + "pack": "si seq pack ./dist/", + "clean": "rm -rf ./dist ./*.tar.gz" + }, + "engines": { + "node": ">=16" + } +} diff --git a/python/hello-world-py/README.md b/python/hello-world-py/README.md new file mode 100644 index 0000000..fe1ba0a --- /dev/null +++ b/python/hello-world-py/README.md @@ -0,0 +1,40 @@ +# Hello world py + +Simple Sequence that outputs "Hello world" written in python + +## Running + +> ❗ Remember to [setup transform-hub locally](https://docs.scramjet.org/platform/self-hosted-installation) or use the [platform's environment](https://docs.scramjet.org/platform/quick-start) for the sequence deployment. + +Open two terminals and run the following commands: + +**The first terminal:** + +Open the terminal and run the following commands: + +```bash +# go to 'hello-world-py' directory +cd python/hello-world-py + +# build +npm run build + +# make a compressed package with Sequence +si seq pack dist + +# send Sequence to transform hub, this will output Sequence ID +si seq send dist.tar.gz + +# start a Sequence +si seq start - +``` + +**The second terminal** + +Read the Instance output: + +```bash +si inst output - +``` + +You should see "Hello World!" printed out in the terminal. diff --git a/python/hello-world-py/hello_world.py b/python/hello-world-py/hello_world.py new file mode 100644 index 0000000..dee05a7 --- /dev/null +++ b/python/hello-world-py/hello_world.py @@ -0,0 +1,12 @@ +from scramjet.streams import Stream + + +async def run(context, input): + # create a clean output stream + stream = Stream() + + # write some data to the output stream + stream.write("Hello World!") + + # return the output stream so it can be consumed (e.g. by CLI client) + return stream diff --git a/python/hello-world-py/package.json b/python/hello-world-py/package.json new file mode 100644 index 0000000..168ec9c --- /dev/null +++ b/python/hello-world-py/package.json @@ -0,0 +1,26 @@ +{ + "name": "@scramjet/hello-world-py", + "version": "1.0.0", + "main": "./hello_world.py", + "author": "S4adam", + "license": "GPL-3.0", + "description": "Simple Sequence that prints out 'Hello World!' to the Instance output.", + "keywords": [ + "sample", + "easy", + "streaming", + "Data Producer" + ], + "repository": { + "type": "git", + "url": "https://github.com/scramjetorg/platform-samples/tree/main/python/hello-world-py" + }, + "scripts": { + "build": "mkdir -p dist/__pypackages__/ && cp *.py package.json dist/ && pip3 install -t dist/__pypackages__/ -r requirements.txt", + "clean": "rm -rf ./dist ./*.tar.gz", + "pack": "si seq pack ./dist/" + }, + "engines": { + "python3": "3.8.0" + } +} diff --git a/python/hello-world-py/requirements.txt b/python/hello-world-py/requirements.txt new file mode 100644 index 0000000..7f2896f --- /dev/null +++ b/python/hello-world-py/requirements.txt @@ -0,0 +1 @@ +scramjet-framework-py diff --git a/typescript/hello-world-ts/README.md b/typescript/hello-world-ts/README.md index c86953b..48082ad 100644 --- a/typescript/hello-world-ts/README.md +++ b/typescript/hello-world-ts/README.md @@ -1,10 +1,14 @@ # Hello world ts -Simple sequence that outputs "Hello world" written in typescript +Simple sequence that outputs "Hello world" written in typescript. ## Running -Open the terminal and run the following commands: +> ❗ Remember to [setup transform-hub locally](https://docs.scramjet.org/platform/self-hosted-installation) or use the [platform's environment](https://docs.scramjet.org/platform/quick-start) for the sequence deployment. + +Open two terminals and run the following commands: + +**The first terminal:** ```bash # install dependencies @@ -22,3 +26,13 @@ si seq send dist.tar.gz # start a Sequence si seq start - ``` + +**The second terminal** + +Read the Instance output: + +```bash +si inst output - +``` + +You should see "Hello World!" printed out in the terminal. diff --git a/typescript/hello-world-ts/package.json b/typescript/hello-world-ts/package.json index 0c330a8..bed5465 100644 --- a/typescript/hello-world-ts/package.json +++ b/typescript/hello-world-ts/package.json @@ -1,21 +1,28 @@ { - "name": "hello-world-ts", + "name": "@scramjet/hello-world-ts", "version": "1.0.0", - "description": "Simple Sequence that prints out 'Hello World!' to the Instance output.", "main": "index.js", + "author": "piotrek6641", + "license": "ISC", + "description": "Simple Sequence that prints out 'Hello World!' to the Instance output.", + "keywords": [ + "sample", + "easy", + "streaming", + "Data Producer" + ], + "repository": { + "type": "git", + "url": "https://github.com/scramjetorg/platform-samples/tree/main/typescript/hello-world-ts" + }, "scripts": { "build": "tsc -p tsconfig.json", "postbuild": "cp -r package.json dist/ && (cd dist && npm i --omit=dev)", "clean": "rm -rf ./dist .bic_cache" }, - "keywords": [ - "easy" - ], "engines": { "node": ">=14" }, - "author": "piotrek6641", - "license": "ISC", "devDependencies": { "@scramjet/types": "^0.33.5", "@types/node": "^20.2.3"