Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hello-world samples #54

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions javascript/hello-world-js/README.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 12 additions & 0 deletions javascript/hello-world-js/index.js
Original file line number Diff line number Diff line change
@@ -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;
};
26 changes: 26 additions & 0 deletions javascript/hello-world-js/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
40 changes: 40 additions & 0 deletions python/hello-world-py/README.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 12 additions & 0 deletions python/hello-world-py/hello_world.py
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions python/hello-world-py/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
1 change: 1 addition & 0 deletions python/hello-world-py/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scramjet-framework-py
18 changes: 16 additions & 2 deletions typescript/hello-world-ts/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
21 changes: 14 additions & 7 deletions typescript/hello-world-ts/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Loading