temporalio / samples-typescript

Other
319 stars 123 forks source link

samples-typescript

Each directory in this repo is a sample Temporal project built with the TypeScript SDK (see docs and API reference).

Running

In browser

The fastest way to try out these samples is running them in the browser:

Locally

Run Temporal Server:

brew install temporal
temporal server start-dev

(or use a different installation method)

Use Node version 16+:

Run the hello-world sample:

git clone https://github.com/temporalio/samples-typescript.git
cd samples-typescript/hello-world
npm i
npm start

and in another terminal:

npm run workflow

Scaffold

To scaffold a new project from one of these samples, run:

npx @temporalio/create@latest my-project --sample sample-name

or:

npx @temporalio/create@latest my-project

and you'll be given the list of sample options.

Samples

Basic

API demos

Activity APIs and design patterns

Workflow APIs

Production APIs

Advanced APIs

Test APIs

Full-stack apps

External apps & libraries

The below projects are maintained outside this repo and may not be up to date.

Contributing

External contributions are very welcome! 🤗 (Big thank you to those who have already contributed 🙏)

Before submitting a major PR, please find consensus on it in Issues.

To get started developing, run:

git clone https://github.com/temporalio/samples-typescript.git
cd samples-typescript
npm install
npm run prepare
npm run bootstrap

Prettier and ESLint are run on each commit, but you can also run them manually:

npm run format
npm run lint

Dependencies

Updating to latest SDK version

lerna exec -- npm update

Upgrading the SDK version in package.jsons

npx zx .scripts/upgrade-versions.mjs 'VERSION_STRING_HERE'
npm run format

Config files

Also on each commit, config files from .shared/ are copied into each sample directory, overwriting the sample directory's config files (with a few exceptions listed in .scripts/copy-shared-files.mjs). So if you're editing config files, you usually want to be editing the versions in .shared/.

The .post-create file is a chalk template that is displayed in the command line after someone uses npx @temporalio/create. If you're adding a sample that requires different instructions from the default message, then add your sample name to POST_CREATE_EXCLUDE and your message template to your-sample/.post-create.