Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v6
with:
package_json_file: typescript/templates/node-gen/package.json
- name: Bump sdk-typescript
run: ./.tools/update_node_examples.sh ${{ inputs.sdkTypescriptVersion }}
- name: Compute paths to commit
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
kotlin-hello-world-lambda-cdk.zip

typescript-hello-world.zip
typescript-hello-world-gen.zip
typescript-hello-world-kubernetes.zip
typescript-hello-world-bun.zip
typescript-hello-world-cloudflare-worker.zip
Expand Down Expand Up @@ -88,6 +89,13 @@ jobs:



copy-ts-gen-template:
name: Copy TypeScript gen template to typescript-gen-template repo
uses: ./.github/workflows/copy-to-repo.yml
secrets: inherit
with:
source-directory: typescript/templates/node-gen
destination-repo: typescript-gen-template
copy-deno-template:
name: Copy deno template to deno-template repo
uses: ./.github/workflows/copy-to-repo.yml
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo '{"ignorePatterns":[{"pattern":"https://docs.restate.dev/_mintlify/feedback/restate-6d46e1dc/agent-feedback"},{"pattern":"https://slack.restate.dev"}]}' > mlc_config.json
- run: echo '{"ignorePatterns":[{"pattern":"https://docs.restate.dev/_mintlify/feedback/restate-6d46e1dc/agent-feedback"},{"pattern":"https://slack.restate.dev"},{"pattern":"^https://www.npmjs.com"}]}' > mlc_config.json
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-verbose-mode: 'yes'
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
RESTATE_DISABLE_TELEMETRY: "true"
strategy:
matrix:
node-version: [22.x]
node-version: [24.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -80,6 +80,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v6
with:
package_json_file: typescript/templates/node-gen/package.json

- name: Run tests
run: ./.tools/run_node_tests.sh
Expand Down
1 change: 1 addition & 0 deletions .tools/prepare_release_zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ create_release_zip typescript/end-to-end-applications/chat-bot typescript-chat-b
create_release_zip typescript/end-to-end-applications/ai-image-workflows typescript-ai-image-workflows
create_release_zip typescript/patterns-use-cases typescript-patterns-use-cases
create_release_zip typescript/templates/node typescript-hello-world
create_release_zip typescript/templates/node-gen typescript-hello-world-gen
create_release_zip typescript/templates/node-kubernetes typescript-hello-world-kubernetes
create_release_zip typescript/templates/lambda typescript-hello-world-lambda
create_release_zip typescript/templates/bun typescript-hello-world-bun
Expand Down
5 changes: 5 additions & 0 deletions .tools/run_node_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ function npm_install_check() {
npm install --prefix $1 && npm --prefix $1 run build
}

function pnpm_install_check() {
pnpm --dir $1 install && pnpm --dir $1 run check && pnpm --dir $1 run build
}

npm_install_check $PROJECT_ROOT/typescript/basics

npm_install_check $PROJECT_ROOT/typescript/templates/node
pnpm_install_check $PROJECT_ROOT/typescript/templates/node-gen
npm_install_check $PROJECT_ROOT/typescript/templates/node-kubernetes
npm_install_check $PROJECT_ROOT/typescript/templates/lambda
npm_install_check $PROJECT_ROOT/typescript/templates/cloudflare-worker
Expand Down
14 changes: 13 additions & 1 deletion .tools/update_node_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ function bump_restate_sdk_deps() {
console.log(restateDeps.join(' '));
")

# Projects declaring pnpm as packageManager are bumped with pnpm, others with npm
local package_manager=$(node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('$package_json', 'utf8'));
console.log((pkg.packageManager || 'npm').split('@')[0]);
")

# Install each dependency with the new version
for dep in $deps; do
echo "Installing $dep@^$NEW_VERSION in $project_dir"
npm install $dep@^$NEW_VERSION
if [ "$package_manager" == "pnpm" ]; then
pnpm add $dep@^$NEW_VERSION
else
npm install $dep@^$NEW_VERSION
fi
done

# If this is a template directory and has existing agents documentation, update it
Expand All @@ -47,6 +58,7 @@ function bump_restate_sdk_deps() {
# Update all projects with package.json
bump_restate_sdk_deps $PROJECT_ROOT/typescript/basics
bump_restate_sdk_deps $PROJECT_ROOT/typescript/templates/node
bump_restate_sdk_deps $PROJECT_ROOT/typescript/templates/node-gen
bump_restate_sdk_deps $PROJECT_ROOT/typescript/templates/node-kubernetes
bump_restate_sdk_deps $PROJECT_ROOT/typescript/templates/lambda
bump_restate_sdk_deps $PROJECT_ROOT/typescript/templates/typescript-testing
Expand Down
1 change: 1 addition & 0 deletions typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Complete applications built with Restate:
Starter templates for new projects:

- **[Node Template](templates/node)**
- **[Node Generator SDK Template](templates/node-gen)**: Uses the generator-based SDK (`@restatedev/restate-sdk-gen`), with pnpm, TypeScript 7, oxlint and oxfmt.
- **[Node.js Kubernetes Template](templates/node-kubernetes)**: Deploy to Kubernetes with an ingress tunnel and Kubernetes YAML files.
- **[Bun Template](templates/bun)**
- **[CloudFlare Workers Template](templates/cloudflare-worker)**
Expand Down
22 changes: 22 additions & 0 deletions typescript/templates/node-gen/.agents/plugins/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "restatedev-plugin",
"interface": {
"displayName": "Restate"
},
"plugins": [
{
"name": "restatedev",
"source": {
"source": "git-subdir",
"url": "https://github.com/restatedev/skills.git",
"path": "./plugins/restatedev",
"ref": "main"
},
"policy": {
"installation": "AVAILABLE",
"authentication": "ON_INSTALL"
},
"category": "Coding"
}
]
}
13 changes: 13 additions & 0 deletions typescript/templates/node-gen/.claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extraKnownMarketplaces": {
"restatedev-plugin": {
"source": {
"source": "github",
"repo": "restatedev/skills"
}
}
},
"enabledPlugins": {
"restatedev@restatedev-plugin": true
}
}
4 changes: 4 additions & 0 deletions typescript/templates/node-gen/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.*
node_modules
dist
Dockerfile
18 changes: 18 additions & 0 deletions typescript/templates/node-gen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Node
node_modules
dist

# debug
npm-debug.log*
pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# typescript
*.tsbuildinfo

# Restate
.restate
restate-data
pnpm-lock.yaml
5 changes: 5 additions & 0 deletions typescript/templates/node-gen/.oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"printWidth": 100,
"ignorePatterns": ["dist", "pnpm-lock.yaml"]
}
9 changes: 9 additions & 0 deletions typescript/templates/node-gen/.oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["typescript", "unicorn", "oxc", "import", "node"],
"categories": {
"correctness": "error",
"suspicious": "warn"
},
"ignorePatterns": ["dist"]
}
30 changes: 30 additions & 0 deletions typescript/templates/node-gen/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:24-alpine AS build

RUN npm install -g pnpm@12.8.1

WORKDIR /usr/src/app

# copy package.json separately to cache dependencies
COPY package.json pnpm-lock.yaml* ./
RUN pnpm install

COPY . .
RUN pnpm build

RUN pnpm prune --prod

FROM node:24-alpine

# dumb-init helps handling SIGTERM and SIGINT correctly
RUN apk add dumb-init

WORKDIR /usr/src/app
ENV NODE_ENV=production

COPY --from=build --chown=node:node /usr/src/app/package.json ./
COPY --from=build --chown=node:node /usr/src/app/node_modules ./node_modules
COPY --from=build --chown=node:node /usr/src/app/dist ./dist

EXPOSE 9080
USER node
CMD ["dumb-init", "node", "./dist/app.js"]
30 changes: 30 additions & 0 deletions typescript/templates/node-gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Hello world - TypeScript generator SDK example

Sample project configuration of a Restate service using the TypeScript SDK with the generator-based API ([`@restatedev/restate-sdk-gen`](https://www.npmjs.com/package/@restatedev/restate-sdk-gen)).

Have a look at the [TypeScript Quickstart guide](https://docs.restate.dev/get_started/quickstart?sdk=ts) for more information on how to use Restate.

## Requirements

- Node.js 24+
- [pnpm](https://pnpm.io/installation)

## Running

```shell
pnpm install
pnpm dev
```

## Docker

```shell
docker build -t restate-ts-gen-template .
docker run -p 9080:9080 restate-ts-gen-template
```

## Using AI coding tools

If you use Claude Code or Codex, then the Restate plugin will automatically be installed. For Cursor, consult the [skills repo README](https://github.com/restatedev/skills).

Plugin repo: https://github.com/restatedev/skills/tree/main
31 changes: 31 additions & 0 deletions typescript/templates/node-gen/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "restate-ts-gen-template",
"version": "0.0.1",
"private": true,
"description": "Template for TypeScript services running with Restate (https://github.com/restatedev/), using the generator-based SDK",
"type": "module",
"scripts": {
"build": "tsc",
"start": "node ./dist/app.js",
"dev": "node --watch ./src/app.ts",
"typecheck": "tsc --noEmit",
"lint": "oxlint",
"fmt": "oxfmt",
"fmt:check": "oxfmt --check",
"check": "pnpm typecheck && pnpm lint && pnpm fmt:check"
},
"dependencies": {
"@restatedev/restate-sdk": "^1.17.2",
"@restatedev/restate-sdk-gen": "^1.17.2"
},
"devDependencies": {
"@types/node": "^24",
"oxfmt": "^0.71.0",
"oxlint": "^1.86.0",
"typescript": "^7.0.2"
},
"engines": {
"node": ">=24"
},
"packageManager": "pnpm@12.8.1"
}
13 changes: 13 additions & 0 deletions typescript/templates/node-gen/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as restate from "@restatedev/restate-sdk";
import { run, service, type Operation } from "@restatedev/restate-sdk-gen";

const greeter = service({
name: "Greeter",
handlers: {
*greet(name: string): Operation<string> {
return yield* run(async () => `Hello ${name}!`);
},
},
});

restate.serve({ services: [greeter] });
27 changes: 27 additions & 0 deletions typescript/templates/node-gen/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"target": "esnext",
"lib": ["esnext"],
"module": "nodenext",
"moduleResolution": "nodenext",
"types": ["node"],

"rootDir": "./src",
"outDir": "./dist",
"sourceMap": true,

// Run .ts files directly with Node's type stripping, emit .js on build
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,

"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noEmitOnError": true,
"skipLibCheck": true
},
"include": ["src"]
}
Loading