From 46f774299b543890a9d71efc5e2b0f4f35d174aa Mon Sep 17 00:00:00 2001 From: Hong Minhee Date: Sun, 31 Mar 2024 16:12:14 +0900 Subject: [PATCH] Add type decls to npm and update docs --- README.md | 51 ++++++++++++++++++++++++++++++++++++++++--- dnt.ts | 2 ++ docs/install.md | 57 +++++++++++++++++++++++++++++++++++++++++++++--- docs/tutorial.md | 19 +++++++++------- 4 files changed, 115 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0077eaea..b4a872c6 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,29 @@ join our [Matrix chat space][Matrix] or [GitHub Discussions]. Installation ------------ -As a prerequisite, you need to have [Deno] 1.41.0 or later installed on your -system. Then you can install Fedify via the following command: +Fedify is available on [JSR] for [Deno] and on [npm] for [Node.js] and [Bun]. +Although Fedify can be used in Node.js and Bun, it's primarily designed for +Deno. We recommend using Deno for the best experience, but you can use Node.js +or Bun if you prefer. + +> [!TIP] +> If you are new to Deno, but already familiar with Node.js, you can think of +> Deno as a more modern version of Node.js created by the same person, Ryan +> Dahl. Deno has a lot of improvements over Node.js, such as better security, +> better TypeScript support, better ES module support, and built-in key-value +> store and message queue. + +[JSR]: https://jsr.io/@fedify/fedify +[Deno]: https://deno.com/ +[npm]: https://www.npmjs.com/package/@fedify/fedify +[Node.js]: https://nodejs.org/ +[Bun]: https://bun.sh/ + +### Deno + +[Deno] is the primary runtime for Fedify. As a prerequisite, you need to have +Deno 1.41.0 or later installed on your system. Then you can install Fedify +via the following command: ~~~~ sh deno add @fedify/fedify @@ -94,4 +115,28 @@ Or you can directly import it in your code using `jsr:` specifier: import { Federation } from "jsr:@fedify/fedify"; ~~~~ -[Deno]: https://deno.com/ +### Node.js + +Fedify can also be used in Node.js. You can install it via the following +command: + +~~~~ sh +npm add @fedify/fedify +~~~~ + +~~~~ typescript +import { Federation } from "@fedify/fedify"; +~~~~ + +### Bun + +Fedify can also be used in Bun. You can install it via the following +command: + +~~~~ sh +bun add @fedify/fedify +~~~~ + +~~~~ typescript +import { Federation } from "@fedify/fedify"; +~~~~ diff --git a/dnt.ts b/dnt.ts index be7a747b..6d712bdc 100644 --- a/dnt.ts +++ b/dnt.ts @@ -65,6 +65,8 @@ await build({ ], }, typeCheck: "both", + declaration: "separate", + declarationMap: true, compilerOptions: { target: "ES2022", }, diff --git a/docs/install.md b/docs/install.md index 4908502c..ccc1469c 100644 --- a/docs/install.md +++ b/docs/install.md @@ -6,8 +6,31 @@ metas: Installation ============ -As a prerequisite, you need to have [Deno] 1.41.0 or later installed on your -system. Then you can install Fedify via the following command: +Fedify is available on [JSR] for [Deno] and on [npm] for [Node.js] and [Bun]. +Although Fedify can be used in Node.js and Bun, it's primarily designed for +Deno. We recommend using Deno for the best experience, but you can use Node.js +or Bun if you prefer. + +> [!TIP] +> If you are new to Deno, but already familiar with Node.js, you can think of +> Deno as a more modern version of Node.js created by the same person, Ryan +> Dahl. Deno has a lot of improvements over Node.js, such as better security, +> better TypeScript support, better ES module support, and built-in key-value +> store and message queue. + +[JSR]: https://jsr.io/@fedify/fedify +[Deno]: https://deno.com/ +[npm]: https://www.npmjs.com/package/@fedify/fedify +[Node.js]: https://nodejs.org/ +[Bun]: https://bun.sh/ + + +Deno +---- + +[Deno] is the primary runtime for Fedify. As a prerequisite, you need to have +Deno 1.41.0 or later installed on your system. Then you can install Fedify +via the following command: ~~~~ sh deno add @fedify/fedify @@ -23,4 +46,32 @@ Or you can directly import it in your code using `jsr:` specifier: import { Federation } from "jsr:@fedify/fedify"; ~~~~ -[Deno]: https://deno.com/ + +Node.js +------- + +Fedify can also be used in Node.js. You can install it via the following +command: + +~~~~ sh +npm add @fedify/fedify +~~~~ + +~~~~ typescript +import { Federation } from "@fedify/fedify"; +~~~~ + + +Bun +--- + +Fedify can also be used in Bun. You can install it via the following +command: + +~~~~ sh +bun add @fedify/fedify +~~~~ + +~~~~ typescript +import { Federation } from "@fedify/fedify"; +~~~~ diff --git a/docs/tutorial.md b/docs/tutorial.md index f7ef0fd8..3d0b1bad 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -18,15 +18,18 @@ receiving activities, and the inbox. As prerequisite knowledge, you should have a basic understanding of JavaScript/TypeScript, command-line interfaces, and minimum experience with building web server apps. However, it's perfectly fine if you're not familiar -with the ActivityPub protocol or the Deno runtime;[^1] we will explain them as +with the ActivityPub protocol or the Deno runtime; we will explain them as we go. -[^1]: The Deno runtime is a secure runtime for JavaScript and TypeScript. It is - similar to Node.js but has a few differences, such as a built-in - TypeScript compiler and a secure-by-default design. If you are already - familiar with Node.js, you can think of Deno as a more modern version of - Node.js. Fun fact: Deno is created by Ryan Dahl, the original creator of - Node.js. +> [!NOTE] +> The Deno runtime is a secure runtime for JavaScript and TypeScript. It is +> similar to Node.js but has a few differences, such as a built-in +> TypeScript compiler and a secure-by-default design. If you are already +> familiar with Node.js, you can think of Deno as a more modern version of +> Node.js created by the same person, Ryan Dahl. +> +> Although this tutorial is written for Deno, you can use the Fedify framework +> in Node.js as well. The API is the same in both Deno and Node.js. What we will build @@ -161,7 +164,7 @@ a key-value store. > [!IMPORTANT] > Since `MemoryKvStore` is for testing and development purposes, you should -> use a persistent key-value store like [`DenoKvStore`] for production use. +> use a persistent key-value store like `DenoKvStore` for production use. Then, we pass the incoming `Request` to the `federation.handle()` method: