diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index a15ef76c..02b55341 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -189,12 +189,7 @@ export default defineConfig({ ? llmstxt({ description: 'Ergonomic Framework for Humans', details: description, - ignoreFiles: [ - 'index.md', - 'table-of-content.md', - 'blog/*', - 'public/*' - ], + ignoreFiles: ['index.md', 'table-of-contents.md', 'blog/*', 'public/*'], domain: 'https://elysiajs.com' }) : undefined, @@ -211,10 +206,7 @@ export default defineConfig({ ] }, ssr: { - noExternal: [ - '@nolebase/vitepress-plugin-inline-link-preview', - '@nolebase/ui' - ] + noExternal: ['@nolebase/vitepress-plugin-inline-link-preview', '@nolebase/ui'] } }, themeConfig: { @@ -228,7 +220,7 @@ export default defineConfig({ nav: [ { text: 'Docs', - link: '/table-of-content' + link: '/table-of-contents' }, { text: 'Blog', @@ -245,7 +237,7 @@ export default defineConfig({ collapsed: true, items: [ { - text: 'At Glance', + text: 'At a Glance', link: '/at-glance' }, { @@ -253,12 +245,12 @@ export default defineConfig({ link: '/quick-start' }, { - text: 'Table of Content', - link: '/table-of-content' + text: 'Table of Contents', + link: '/table-of-contents' }, { - text: 'Key Concept', - link: '/key-concept' + text: 'Key Concepts', + link: '/key-concepts' } ] }, @@ -568,8 +560,7 @@ export default defineConfig({ ], editLink: { text: 'Edit this page on GitHub', - pattern: - 'https://github.com/elysiajs/documentation/edit/main/docs/:path' + pattern: 'https://github.com/elysiajs/documentation/edit/main/docs/:path' } } }) diff --git a/docs/at-glance.md b/docs/at-glance.md index 574a5ae1..c496c71f 100644 --- a/docs/at-glance.md +++ b/docs/at-glance.md @@ -1,9 +1,9 @@ --- -title: At glance - ElysiaJS +title: At a glance - ElysiaJS head: - - meta - property: 'og:title' - content: At glance - ElysiaJS + content: At a glance - ElysiaJS - - meta - name: 'description' @@ -299,7 +299,7 @@ With Eden, you can use the existing Elysia types to query an Elysia server **wit Elysia is not only about helping you create a confident backend but for all that is beautiful in this world. ## Type Soundness -Most frameworks with end-to-end type safety usually assume only a happy part, leaving error handling and edge cases out of the type system. +Most frameworks with end-to-end type safety usually assume only a happy path, leaving error handling and edge cases out of the type system. However, Elysia can infers all of the possible outcomes of your API, from lifecycle events/macro from any part of your codebase. @@ -439,7 +439,7 @@ Elysia is **used in production by many companies and projects worldwide**, inclu Elysia is a reliable choice and production ready for building your next backend server. -Here's on of our community resources to get you started: +Here are some of our community resources to get you started: diff --git a/docs/components/xiao/table-of-content.ts b/docs/components/xiao/table-of-content.ts index 6ae8b644..6a0de650 100644 --- a/docs/components/xiao/table-of-content.ts +++ b/docs/components/xiao/table-of-content.ts @@ -108,8 +108,8 @@ export const tableOfContents: TableOfContentGroup[] = [ href: '/tutorial/whats-next' }, { - title: 'Documentation', - href: '/table-of-content' + title: 'Documentation', + href: '/table-of-contents' } ] } diff --git a/docs/essential/plugin.md b/docs/essential/plugin.md index 931119c4..7d35a1cf 100644 --- a/docs/essential/plugin.md +++ b/docs/essential/plugin.md @@ -162,7 +162,7 @@ The plugin will inherit all properties of the plugin instance like `state`, `dec Elysia will also handle the type inference automatically as well. ::: tip -It's highly recommended that you have read [Key Concept: Dependency](/key-concept.html#dependency) before continuing. +It's highly recommended that you have read [Key Concept: Dependency](/key-concepts.html#dependency) before continuing. ::: @@ -218,12 +218,12 @@ This approach force you to be explicit about dependencies allowing better tracki By default, each plugin will be re-executed **every time** applying to another instance. -To prevent this, Elysia can deduplicate [lifecycle](/essential/life-cycle) with **an unique identifier** using `name` and optional `seed` property. +To prevent this, Elysia can deduplicate [lifecycle](/essential/life-cycle) with **a unique identifier** using `name` and an optional `seed` property. ```ts twoslash import { Elysia } from 'elysia' -// `name` is an unique identifier +// `name` is a unique identifier const ip = new Elysia({ name: 'ip' }) // [!code ++] .derive( { as: 'global' }, diff --git a/docs/key-concept.md b/docs/key-concepts.md similarity index 76% rename from docs/key-concept.md rename to docs/key-concepts.md index 00dce29d..53d1a17c 100644 --- a/docs/key-concept.md +++ b/docs/key-concepts.md @@ -1,9 +1,9 @@ --- -title: Key Concept - ElysiaJS +title: Key Concepts - ElysiaJS head: - - meta - property: 'og:title' - content: Key Concept - ElysiaJS + content: Key Concepts - ElysiaJS - - meta - name: 'description' @@ -37,16 +37,16 @@ const demo2 = new Elysia() .patch('/rename', ({ status }) => status(401)) -# Key Concept +# Key Concepts -Elysia has a every important concepts that you need to understand to use. +Elysia has important concepts that you need to understand to use it effectively. -This page covers most concepts that you should know before getting started. +This page covers most of the concepts that you should know before getting started. ## Encapsulation Elysia lifecycle methods are **encapsulated** to its own instance only. -Which means if you create a new instance, it will not share the lifecycle methods with others. +This means if you create a new instance, it will not share the lifecycle methods with others. ```ts import { Elysia } from 'elysia' @@ -72,9 +72,9 @@ In this example, the `isSignIn` check will only apply to `profile` but not `app`
-**Elysia isolate lifecycle by default** unless explicitly stated. This is similar to **export** in JavaScript, where you need to export the function to make it available outside the module. +**Elysia isolates lifecycle by default** unless explicitly stated. This is similar to **export** in JavaScript, where you need to export the function to make it available outside the module. -To **"export"** the lifecycle to other instances, you must add specify the scope. +To **"export"** the lifecycle to other instances, you must specify the scope. ```ts import { Elysia } from 'elysia' @@ -147,7 +147,7 @@ new Elysia() In the code above, **state** returns a new **ElysiaInstance** type, adding a typed `build` property. ### Without method chaining -As Elysia type system is complex, every method in Elysia returns a new type reference. +As Elysia's type system is complex, every method in Elysia returns a new type reference. Without using method chaining, Elysia doesn't save these new types, leading to no type inference. @@ -167,11 +167,11 @@ app.listen(3000) We recommend to **always use method chaining** to provide an accurate type inference. ## Dependency -Elysia by design, is compose of multiple mini Elysia apps which can run **independently** like a microservice that communicate with each other. +Elysia, by design, is composed of multiple mini Elysia apps which can run **independently**, like microservices that communicate with each other. Each Elysia instance is independent and **can run as a standalone server**. -When an instance need to use another instance's service, you **must explicitly declare the dependency**. +When an instance needs to use another instance's service, you **must explicitly declare the dependency**. ```ts twoslash // @errors: 2339 @@ -210,20 +210,20 @@ const main = new Elysia() // ---cut-after--- ``` -This is similar to **Dependency Injection** where each instance must declare its dependencies. +This is similar to **Dependency Injection**, where each instance must declare its dependencies. -This approach force you to be explicit about dependencies allowing better tracking, modularity. +This approach forces you to be explicit about dependencies allowing better tracking and modularity. ### Deduplication -By default, each plugin will be re-executed **every time** applying to another instance. +By default, each plugin will be re-executed **every time** it is used by another instance. -To prevent this, Elysia can deduplicate lifecycle with **an unique identifier** using `name` and optional `seed` property. +To prevent this, Elysia can deduplicate lifecycle with **a unique identifier**, using `name` and an optional `seed` property. ```ts twoslash import { Elysia } from 'elysia' -// `name` is an unique identifier +// `name` is a unique identifier const ip = new Elysia({ name: 'ip' }) // [!code ++] .derive( { as: 'global' }, @@ -246,17 +246,17 @@ const server = new Elysia() .use(router2) ``` -Adding the `name` and optional `seed` to the instance will make it a unique identifier prevent it from being called multiple times. +Adding the `name` and optional `seed` to the instance will make it unique and prevent it from being called multiple times. Learn more about this in [plugin deduplication](/essential/plugin.html#plugin-deduplication). ### Global vs Explicit Dependency -There are some case that global dependency make more sense than an explicit one. +There are some cases that global dependency makes more sense than an explicit one. **Global** plugin example: -- **Plugin that doesn't add types** - eg. cors, compress, helmet -- Plugin that add global lifecycle that no instance should have control over - eg. tracing, logging +- **Plugins that don't add types** - eg. cors, compress, helmet +- Plugins that add global lifecycle that no instance should have control over - eg. tracing, logging Example use cases: - OpenAPI/Open - Global document @@ -268,8 +268,8 @@ In case like this, it make more sense to create it as global dependency instead However, if your dependency doesn't fit into these categories, it's recommended to use **explicit dependency** instead. **Explicit dependency** example: -- **Plugin that add types** - eg. macro, state, model -- Plugin that add business logic that instance can interact with - eg. Auth, Database +- **Plugins that add types** - eg. macro, state, model +- Plugins that add business logic that instances can interact with - eg. Auth, Database Example use cases: - State management - eg. Store, Session @@ -281,9 +281,9 @@ Example use cases: The order of Elysia's life-cycle code is very important. -Because event will only apply to routes **after** it is registered. +Because events will only apply to routes **after** it is registered. -If you put the onError before plugin, plugin will not inherit the onError event. +If you put the `onBeforeHandle` after the get route handler, it will not execute that lifecycle handler. Consider the following: ```typescript import { Elysia } from 'elysia' @@ -330,7 +330,7 @@ const app = new Elysia() You should **always use an inline function** to provide an accurate type inference. -If you need to apply a separate function, eg. MVC's controller pattern, it's recommended to destructure properties from inline function to prevent unnecessary type inference as follows: +If you need to apply a separate function, eg. MVC's controller pattern, it's recommended to destructure properties in inline functions to prevent unnecessary type inference as follows: ```ts twoslash import { Elysia, t } from 'elysia' @@ -352,7 +352,7 @@ const app = new Elysia() See [Best practice: MVC Controller](/essential/best-practice.html#controller). ### TypeScript -We can get a type definitions of every Elysia/TypeBox's type by accessing `static` property as follows: +We can get type definitions of every Elysia/TypeBox's type by accessing `static` property as follows: ```ts twoslash import { t } from 'elysia' @@ -369,7 +369,7 @@ type MyType = typeof MyType.static

-This allows Elysia to infer and provide type automatically, reducing the need to declare duplicate schema +This allows Elysia to infer and provide types automatically, reducing the need to declare duplicate schemas. A single Elysia/TypeBox schema can be used for: - Runtime validation diff --git a/docs/migrate/index.md b/docs/migrate/index.md index bdede92c..6c271a95 100644 --- a/docs/migrate/index.md +++ b/docs/migrate/index.md @@ -4,7 +4,7 @@ import Deck from '../components/nearl/card-deck.vue' - + The core concept of Elysia and how to use it. diff --git a/docs/quick-start.md b/docs/quick-start.md index e29e729c..85ef1978 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -272,7 +272,7 @@ To create a new Elysia app with JavaScript, start by installing Elysia: ::: code-group -```bash [pnpm] +```bash [bun] bun add elysia @elysiajs/node ``` @@ -314,7 +314,7 @@ Open your `package.json` file and add the following scripts: ```json { - "type", "module", + "type": "module", "scripts": { "dev": "node src/index.ts", "start": "NODE_ENV=production node src/index.js" diff --git a/docs/table-of-content.md b/docs/table-of-contents.md similarity index 80% rename from docs/table-of-content.md rename to docs/table-of-contents.md index f17bfa5e..f36ff702 100644 --- a/docs/table-of-content.md +++ b/docs/table-of-contents.md @@ -1,9 +1,9 @@ --- -title: Table of Content - ElysiaJS +title: Table of Contents - ElysiaJS head: - - meta - property: 'og:title' - content: Table of Content - ElysiaJS + content: Table of Contents - ElysiaJS - - meta - name: 'description' @@ -21,7 +21,7 @@ head: import TutorialLink from './components/xiao/tutorial-link.vue' -# Table of Content +# Table of Contents There's no correct way to learn Elysia, but we **highly recommended** you checkout the an **Interactive Tutorial** first to get familiar with Elysia: @@ -33,11 +33,11 @@ Although Elysia's documentation is designed to be beginner-friendly, we need to To get the most out of our documentation, it's recommended that you have a basic understanding of Node.js and basic HTTP.--> ## First up -We highly recommended you to check out these 2 pages first before getting started with Elysia: +We highly recommended you check out these 2 pages first before getting started with Elysia: - - Core concept of Elysia and how to effectively + + Core concepts of Elysia and how to use it Understand best practice to write Elysia code @@ -54,14 +54,14 @@ bunx skills add elysiajs/skills - Download summarized Elysia doc in Markdown format with reference for prompting LLMs + Download summarized Elysia docs in Markdown format with reference for prompting LLMs - Download full Elysia doc in Markdown format in a single file for prompting LLMs + Download full Elysia docs in Markdown format in a single file for prompting LLMs -## From other Framework? +## From another Framework? If you have used other popular frameworks like Express, Fastify, or Hono, you will find Elysia right at home with just a few differences. @@ -82,41 +82,41 @@ If you have used other popular frameworks like Express, Fastify, or Hono, you wi ## Essential Chapter -Here are the foundation of Elysia, we highly recommended you to go through these pages before jumping to other topics: +These are the core features of Elysia; we highly recommended you go through these pages before jumping to other topics: Understand how routing works in Elysia - Learn about how to handle request + Learn about handling requests - + How to enforce type safety with Elysia - - Learn different type of lifecycle + + Learn the lifecycle events of requests - Learn how to extend Elysia with Plugin + Learn how to extend Elysia with Plugins ## More Patterns -If you feels like exploring more Elysia feature, check out: +If you feel like exploring more Elysia features, check out: - - More pattern on how to send a file, Server Sent Event, etc. + + More patterns on how to send a file, Server Sent Events, etc. - See how to create Real Time application with Elysia + See how to create Real Time applications with Elysia - Learn more about Eden, and how to use it effectively + Learn more about Eden, Elysia's RPC-like client - + Learn how to monitor your application with Open Telemetry @@ -124,9 +124,9 @@ If you feels like exploring more Elysia feature, check out: -## Integration with Meta Framework +## Integration with Meta Frameworks -We can also use Elysia with Meta Framework like Nextjs, Nuxt, Astro, etc. +We can also use Elysia with Meta Frameworks like Nextjs, Nuxt, Astro, etc. diff --git a/docs/tutorial/getting-started/plugin/index.md b/docs/tutorial/getting-started/plugin/index.md index 6bed1984..a9ea207c 100644 --- a/docs/tutorial/getting-started/plugin/index.md +++ b/docs/tutorial/getting-started/plugin/index.md @@ -66,7 +66,7 @@ new Elysia() .listen(3000) ``` -It's also recommended that you should also read about [Key Concept: Dependency](/key-concept#dependency) to understand how Elysia handles dependencies between plugins. +It's recommended that you should also read about [Key Concept: Dependency](/key-concepts#dependency) to understand how Elysia handles dependencies between plugins. ## Assignment diff --git a/docs/tutorial/whats-next.md b/docs/tutorial/whats-next.md index 3d116703..c5ef5507 100644 --- a/docs/tutorial/whats-next.md +++ b/docs/tutorial/whats-next.md @@ -38,8 +38,8 @@ Now you're ready to build your own application with Elysia! We highly recommended you to check out these 2 pages first before getting started with Elysia: - - Core concept of Elysia and how to effectively + + Core concepts of Elysia and how to use them Understand best practice to write Elysia code @@ -52,10 +52,10 @@ Alternatively, you can download llms.txt or - Download summarized Elysia doc in Markdown format with reference for prompting LLMs + Download summarized Elysia docs in Markdown format with reference for prompting LLMs - Download full Elysia doc in Markdown format in a single file for prompting LLMs + Download full Elysia docs in Markdown format in a single file for prompting LLMs @@ -105,10 +105,10 @@ Here are the foundation of Elysia, we highly recommended you to go through these Learn about how to handle request - + How to enforce type safety with Elysia - + Learn different type of lifecycle @@ -121,14 +121,14 @@ Here are the foundation of Elysia, we highly recommended you to go through these If you feels like exploring more Elysia feature, check out: - - More pattern on how to send a file, Server Sent Event, etc. + + More patterns on how to send a file, Server Sent Events, etc. See how to create Real Time application with Elysia - Learn more about Eden, and how to use it effectively + Learn more about Eden, Elysia's RPC-like client Learn how to monitor your application with Open Telemetry