diff --git a/typescript/hello-world-ts/README.md b/typescript/hello-world-ts/README.md new file mode 100644 index 0000000..c86953b --- /dev/null +++ b/typescript/hello-world-ts/README.md @@ -0,0 +1,24 @@ +# Hello world ts + +Simple sequence that outputs "Hello world" written in typescript + +## Running + +Open the terminal and run the following commands: + +```bash +# install dependencies +npm install + +# transpile TS->JS to dist/ +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 - +``` diff --git a/typescript/hello-world-ts/index.ts b/typescript/hello-world-ts/index.ts new file mode 100644 index 0000000..dba9950 --- /dev/null +++ b/typescript/hello-world-ts/index.ts @@ -0,0 +1,15 @@ +import { PassThrough } from "stream"; +import { ReadableApp } from "@scramjet/types"; + +const app: ReadableApp = 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; +}; + +export default app; diff --git a/typescript/hello-world-ts/package.json b/typescript/hello-world-ts/package.json new file mode 100644 index 0000000..0c330a8 --- /dev/null +++ b/typescript/hello-world-ts/package.json @@ -0,0 +1,26 @@ +{ + "name": "hello-world-ts", + "version": "1.0.0", + "description": "Simple Sequence that prints out 'Hello World!' to the Instance output.", + "main": "index.js", + "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" + }, + "dependencies": { + "typescript": "^5.0.4" + } +} diff --git a/typescript/hello-world-ts/tsconfig.json b/typescript/hello-world-ts/tsconfig.json new file mode 100644 index 0000000..4f0fb38 --- /dev/null +++ b/typescript/hello-world-ts/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "lib": [ "ESNext" ], + "target": "ESNext", + "module": "CommonJS", + "outDir": "./dist", + "esModuleInterop": true, + "skipLibCheck": true, + "resolveJsonModule": true, + } +}