diff --git a/docs/modules/README.md b/docs/modules/README.md index 624d224c..a85626a8 100644 --- a/docs/modules/README.md +++ b/docs/modules/README.md @@ -40,6 +40,7 @@ ESLint plugin. - [`eslint-plugin-react`](./eslint-plugin-react.md) - [`eslint-plugin-vitest`](./eslint-plugin-vitest.md) - [`execa`](./execa.md) +- [`express`](./express.md) - [`ezspawn`](./ez-spawn.md) - [`faker`](./faker.md) - [`fast-glob`](./fast-glob.md) diff --git a/docs/modules/express.md b/docs/modules/express.md new file mode 100644 index 00000000..eb276310 --- /dev/null +++ b/docs/modules/express.md @@ -0,0 +1,85 @@ +--- +description: Modern alternatives to the express package +--- + +# Replacements for `express` + +Express has been the industry standard for years, but the ecosystem has shifted toward ESM-first, type-safe, and runtime-agnostic frameworks that offer significantly better performance and developer experience. + +## `h3` + +[`h3`](https://github.com/h3js/h3) is a minimal H(TTP) framework built for high performance and portability. + +Example: + + +```ts +import express from 'express' // [!code --] +import { H3, defineHandler, toNodeHandler } from 'h3' // [!code ++] +import { createServer } from 'node:http' // [!code ++] + +const app = express() // [!code --] +const app = new H3() // [!code ++] + +app.get('/', (req, res) => res.send('Hello world')) // [!code --] +app.get('/', defineHandler(() => 'Hello world')) // [!code ++] + +app.listen(3000) // [!code --] +createServer(toNodeHandler(app)).listen(3000) // [!code ++] +``` + +## `tinyhttp` + +[`tinyhttp`](https://github.com/tinyhttp/tinyhttp) is designed to be a drop-in replacement remaining compatible with many Express middlewares. + +Example: + +```ts +import express from 'express' // [!code --] +import { App } from '@tinyhttp/app' // [!code ++] + +const app = express() // [!code --] +const app = new App() // [!code ++] + +app.get('/', (req, res) => res.send('Hello world')) + +app.listen(3000) +``` + +## `hono` + +[`hono`](https://github.com/honojs/hono) is a small, simple, and fast web framework for the Edges. + +Example: + +```ts +import express from 'express' // [!code --] +import { Hono } from 'hono' // [!code ++] + +const app = express() // [!code --] +const app = new Hono() // [!code ++] + +app.get('/', (req, res) => res.send('Hello world')) // [!code --] +app.get('/', (context) => context.text('Hello world')) // [!code ++] + +export default app // [!code ++] +``` + +## `elysia` + +If you are using Bun, [`elysia`](https://github.com/elysiajs/elysia) is often the best choice as it is specifically optimized for the Bun runtime. + +Example: + +```ts +import express from 'express' // [!code --] +import { Elysia } from 'elysia' // [!code ++] + +const app = express() // [!code --] +const app = new Elysia() // [!code ++] + +app.get('/', (req, res) => res.send('Hello world')) // [!code --] +app.get('/', () => 'Hello world') // [!code ++] + +app.listen(3000) +``` diff --git a/manifests/preferred.json b/manifests/preferred.json index bbb650ca..5dfd54b4 100644 --- a/manifests/preferred.json +++ b/manifests/preferred.json @@ -192,6 +192,12 @@ "replacements": ["tinyexec", "nanoexec", "Bun.Shell"], "url": {"type": "e18e", "id": "execa"} }, + "express": { + "type": "module", + "moduleName": "express", + "replacements": ["h3", "tinyhttp", "hono", "elysia"], + "url": {"type": "e18e", "id": "express"} + }, "ez-spawn": { "type": "module", "moduleName": "ez-spawn", @@ -2795,6 +2801,12 @@ "url": {"type": "e18e", "id": "dot-prop"}, "replacementModule": "dlv" }, + "elysia": { + "id": "elysia", + "type": "documented", + "url": {"type": "e18e", "id": "express"}, + "replacementModule": "elysia" + }, "emoji-regex-xs": { "id": "emoji-regex-xs", "type": "documented", @@ -2942,6 +2954,18 @@ "url": {"type": "e18e", "id": "node-telegram-bot-api"}, "replacementModule": "grammy" }, + "h3": { + "id": "h3", + "type": "documented", + "url": {"type": "e18e", "id": "express"}, + "replacementModule": "h3" + }, + "hono": { + "id": "hono", + "type": "documented", + "url": {"type": "e18e", "id": "express"}, + "replacementModule": "hono" + }, "isBuiltin": { "id": "isBuiltin", "type": "native", @@ -3171,6 +3195,12 @@ "url": {"type": "e18e", "id": "fast-glob"}, "replacementModule": "tinyglobby" }, + "tinyhttp": { + "id": "tinyhttp", + "type": "documented", + "url": {"type": "e18e", "id": "express"}, + "replacementModule": "@tinyhttp/app" + }, "unicode-segmenter": { "id": "unicode-segmenter", "type": "documented",