-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cloudflare workers examples * Use /fetch component * Add README
- Loading branch information
1 parent
a32765b
commit 5293cde
Showing
8 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.wrangler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"arrowParens": "always", | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Hello world - Cloudflare workers + Typescript example | ||
|
||
Sample project configuration of a Restate service using the TypeScript SDK and | ||
Cloudflare Workers. | ||
|
||
Have a look at the [TypeScript Quickstart guide](https://docs.restate.dev/get_started/quickstart?sdk=ts) for more information about the SDK. | ||
|
||
You can run locally with `npm run dev` and register to Restate with | ||
`restate dep add http://localhost:9080 --use-http1.1`. `--use-http1.1` is needed | ||
with the local Workers dev server, as it does not expose HTTP2. | ||
|
||
You can deploy to cloudflare with `npm run deploy` and register to Restate with | ||
`restate dep add https://restate-cloudflare-worker.<your-subdomain>.workers.dev`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "restate-cloudflare-worker-template", | ||
"type": "module", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"deploy": "wrangler deploy", | ||
"dev": "wrangler dev --port 9080", | ||
"start": "wrangler dev --port 9080", | ||
"format": "prettier --write \"src/*.+(js|ts|json)\"" | ||
}, | ||
"dependencies": { | ||
"@restatedev/restate-sdk": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"@cloudflare/workers-types": "^4.20240605.0", | ||
"prettier": "^3.3.2", | ||
"typescript": "^5.4.5", | ||
"wrangler": "^3.0.0" | ||
}, | ||
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Context, endpoint, service } from "@restatedev/restate-sdk/fetch"; | ||
|
||
// Template of a Restate service and handler | ||
// | ||
// Have a look at the TS QuickStart: https://docs.restate.dev/get_started/quickstart?sdk=ts | ||
// | ||
|
||
const greeter = service({ | ||
name: "greeter", | ||
handlers: { | ||
greet: async (ctx: Context, greeting: string) => { | ||
return `${greeting}!`; | ||
}, | ||
}, | ||
}); | ||
|
||
export default endpoint().bind(greeter).handler(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"noEmit": true, | ||
"module": "nodenext", | ||
"target": "esnext", | ||
"lib": ["esnext"], | ||
"strict": true, | ||
"moduleResolution": "nodenext", | ||
"types": ["@cloudflare/workers-types"], | ||
"skipLibCheck": true | ||
}, | ||
"exclude": ["node_modules", "dist", "test"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name = "restate-cloudflare-worker" | ||
main = "./src/index.ts" | ||
compatibility_date = "2024-05-13" | ||
compatibility_flags = [ "nodejs_compat" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters