@@ -7,14 +7,15 @@ A comprehensive example of building a federated server application using
77[ Fedify] with [ Astro] via the [ ` @fedify/astro ` ] package. This sample
88demonstrates how to create an ActivityPub-compatible federated social media
99server that can interact with other federated platforms like Mastodon, Pleroma,
10- and other ActivityPub implementations. It supports both [ Deno] and [ Node.js]
11- runtimes.
10+ and other ActivityPub implementations. It supports [ Deno] , [ Node.js] , and
11+ [ Bun ] runtimes.
1212
1313[ Fedify ] : https://fedify.dev
1414[ Astro ] : https://astro.build/
1515[ `@fedify/astro` ] : https://jsr.io/@fedify/astro
1616[ Deno ] : https://deno.com/
1717[ Node.js ] : https://nodejs.org/
18+ [ Bun ] : https://bun.sh/
1819
1920
2021Features
@@ -30,7 +31,8 @@ Features
3031 - ** Inbox Processing** : Real-time activity processing from federated instances
3132 - ** Content Negotiation** : Same routes serve HTML for browsers and ActivityPub
3233 JSON for federated clients
33- - ** Dual Runtime** : Supports both Deno and Node.js via separate Astro configs
34+ - ** Three Runtimes** : Supports Deno, Node.js, and Bun via separate Astro
35+ configs
3436 - ** TypeScript** : Full type safety throughout the application
3537
3638
@@ -40,8 +42,10 @@ How it works
4042 - * astro.config.deno.ts* registers ` fedifyIntegration() ` to configure Vite's
4143 SSR settings for Fedify compatibility, and uses ` @deno/astro-adapter ` to
4244 run on Deno.
43- - * astro.config.node.ts* registers ` fedifyIntegration() ` without any adapter
44- for Node.js.
45+ - * astro.config.node.ts* registers ` fedifyIntegration() ` and uses
46+ ` @astrojs/node ` for Node.js.
47+ - * astro.config.bun.ts* registers ` fedifyIntegration() ` and uses
48+ ` @nurodev/astro-bun ` for Bun.
4549 - * src/lib/store.ts* defines in-memory stores for key pairs, follower
4650 relationships, and posts.
4751 - * src/lib/federation.ts* sets up the full ` Federation ` instance with:
@@ -111,6 +115,23 @@ pnpm dev
111115
112116This uses * astro.config.node.ts* as the configuration file.
113117
118+ ### Bun
119+
120+ To run the dev server with Bun:
121+
122+ ~~~~ command
123+ bun run dev:bun
124+ ~~~~
125+
126+ This uses * astro.config.bun.ts* as the configuration file.
127+
128+ To build and run the Bun server bundle:
129+
130+ ~~~~ command
131+ bun run build:bun
132+ bun run preview:bun
133+ ~~~~
134+
114135### Testing
115136
116137The application will be available at < http://localhost:4321/ > .
@@ -139,6 +160,8 @@ Example usage scenarios
139160 deno task dev
140161 # or for Node.js
141162 pnpm dev
163+ # or for Bun
164+ bun run dev:bun
142165 ~~~~
143166
1441672. Visit the home page at < http://localhost:4321/> to see the demo account
@@ -216,13 +239,13 @@ Using as a template
216239-------------------
217240
218241If you are creating a new project based on this example, you only need the
219- configuration file for your target runtime. Delete the unused one and rename
242+ configuration file for your target runtime. Delete the unused ones and rename
220243the one you keep to * astro.config.ts* :
221244
222245### For Deno
223246
224247~~~~ command
225- rm astro.config.node.ts
248+ rm astro.config.node.ts astro.config.bun.ts
226249mv astro.config.deno.ts astro.config.ts
227250~~~~
228251
@@ -241,7 +264,7 @@ Then remove the `--config` flags from *deno.json* tasks:
241264### For Node.js
242265
243266~~~~ command
244- rm astro.config.deno.ts
267+ rm astro.config.deno.ts astro.config.bun.ts
245268mv astro.config.node.ts astro.config.ts
246269~~~~
247270
@@ -257,6 +280,25 @@ Then remove the `--config` flags from *package.json* scripts:
257280}
258281~~~~
259282
283+ ### For Bun
284+
285+ ~~~~ command
286+ rm astro.config.deno.ts astro.config.node.ts
287+ mv astro.config.bun.ts astro.config.ts
288+ ~~~~
289+
290+ Then update * package.json* scripts to use Bun's SSR entry point after build:
291+
292+ ~~~~ json
293+ {
294+ "scripts" : {
295+ "dev" : " bunx astro dev" ,
296+ "build" : " bunx astro build" ,
297+ "preview" : " bun ./dist/server/entry.mjs"
298+ }
299+ }
300+ ~~~~
301+
260302
261303Links
262304-----
0 commit comments