-
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.
- Loading branch information
1 parent
5293cde
commit 8c1b284
Showing
9 changed files
with
106 additions
and
2 deletions.
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,10 @@ | ||
# Hello world - Bun example | ||
|
||
Sample project configuration of a Restate service using the TypeScript SDK and | ||
Bun. | ||
|
||
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 | ||
always needed with Bun, as it does not yet support HTTP2. |
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,18 @@ | ||
{ | ||
"name": "restate-bun-template", | ||
"type": "module", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"dev": "bun run --watch src/index.ts", | ||
"start": "bun run src/index.ts", | ||
"format": "prettier --write \"src/*.+(js|ts|json)\"" | ||
}, | ||
"dependencies": { | ||
"@restatedev/restate-sdk": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/bun": "^1.1.5", | ||
"prettier": "^3.3.2", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
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,24 @@ | ||
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}!`; | ||
}, | ||
}, | ||
}); | ||
|
||
const handler = endpoint().bind(greeter).handler(); | ||
|
||
const server = Bun.serve({ | ||
port: 9080, | ||
...handler, | ||
}); | ||
|
||
console.log(`Listening on ${server.url}`); |
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,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"noEmit": true, | ||
"module": "nodenext", | ||
"target": "esnext", | ||
"lib": ["esnext"], | ||
"strict": true, | ||
"moduleResolution": "nodenext", | ||
"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 |
---|---|---|
|
@@ -16,6 +16,5 @@ | |
"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 @@ | ||
deno.lock |
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,15 @@ | ||
# Hello world - Deno example | ||
|
||
Sample project configuration of a Restate service using the TypeScript SDK and | ||
Deno. | ||
|
||
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 `deno task dev` and register to Restate with | ||
`restate dep add http://localhost:9080 --use-http1.1`. `--use-http1.1` is | ||
currently needed with local Deno as we do not support Deno's HTTP2 | ||
implementation yet. | ||
|
||
You can deploy to Deno Deploy with `deployctl deploy` and register to Restate | ||
with | ||
`restate dep add https://<your-project-subdomain>.deno.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,6 @@ | ||
{ | ||
"tasks": { | ||
"dev": "deno run --allow-net --allow-env --watch main.ts", | ||
"start": "deno run --allow-net --allow-env main.ts" | ||
} | ||
} |
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,19 @@ | ||
import { Context, endpoint, service } from "npm:@restatedev/restate-sdk@^1.0.1/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}!`; | ||
}, | ||
}, | ||
}); | ||
|
||
const handler = endpoint().bind(greeter).handler(); | ||
|
||
Deno.serve({ port: 9080 }, handler.fetch); |