@web-ts-toolkit/express-runtime 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -10
- package/cli.js +2 -7
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ pnpm add @web-ts-toolkit/express-runtime express
|
|
|
25
25
|
shutdown that drains in-flight requests, and a configurable timeout.
|
|
26
26
|
- CLI binary with three subcommands:
|
|
27
27
|
- `dev` — run an Express app as a local dev server
|
|
28
|
-
- `build` — bundle the app as a serverless handler
|
|
28
|
+
- `build` — bundle the app as a serverless handler
|
|
29
29
|
- `start` — smoke-test the bundled handler locally by translating HTTP ↔ serverless events
|
|
30
30
|
|
|
31
31
|
## Quick Start
|
|
@@ -134,8 +134,7 @@ npx tsx ./node_modules/@web-ts-toolkit/express-runtime/dist/cli.js dev ./src/app
|
|
|
134
134
|
### CLI — build (serverless bundle)
|
|
135
135
|
|
|
136
136
|
The `build` command generates a temporary serverless entry that wraps the app
|
|
137
|
-
with `createServerlessHandler`, then bundles it
|
|
138
|
-
deployment-ready file:
|
|
137
|
+
with `createServerlessHandler`, then bundles it into a deployment-ready file:
|
|
139
138
|
|
|
140
139
|
```sh
|
|
141
140
|
npx wtt-express-runtime build ./src/app.ts --out-dir netlify/functions
|
|
@@ -158,8 +157,8 @@ This produces `netlify/functions/handler.js` (configurable via `--out-name`)
|
|
|
158
157
|
that exports a `handler` function compatible with Netlify, Vercel, AWS Lambda,
|
|
159
158
|
and any platform that calls `(event, context)`.
|
|
160
159
|
|
|
161
|
-
> `
|
|
162
|
-
>
|
|
160
|
+
> `express` is always external; additional externals can be added via
|
|
161
|
+
> `--external`.
|
|
163
162
|
|
|
164
163
|
### CLI — start (run a bundled handler locally)
|
|
165
164
|
|
|
@@ -302,7 +301,7 @@ Omitting `<command>` defaults to `dev` for backward compatibility.
|
|
|
302
301
|
| Command | Description |
|
|
303
302
|
| ------- | ----------------------------------------------------------------------------------- |
|
|
304
303
|
| `dev` | Run the Express app as a local dev server (`http.createServer` + graceful shutdown) |
|
|
305
|
-
| `build` | Bundle the Express app as a serverless handler
|
|
304
|
+
| `build` | Bundle the Express app as a serverless handler |
|
|
306
305
|
| `start` | Run a bundled serverless handler locally (HTTP ↔ serverless event adapter) |
|
|
307
306
|
|
|
308
307
|
#### dev options
|
|
@@ -357,10 +356,10 @@ exit the process after the server drains. TypeScript app modules require a TS
|
|
|
357
356
|
loader (see the Quick Start CLI section for a `tsx` invocation).
|
|
358
357
|
|
|
359
358
|
The `build` command generates a temporary entry file that imports the app
|
|
360
|
-
module and wraps it with `createServerlessHandler`, then
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
359
|
+
module and wraps it with `createServerlessHandler`, then produces a
|
|
360
|
+
self-contained bundle. `express` is always external; all other dependencies
|
|
361
|
+
(including `@web-ts-toolkit/express-runtime` and `serverless-http`) are
|
|
362
|
+
bundled into the output unless marked external via `--external`.
|
|
364
363
|
|
|
365
364
|
## License
|
|
366
365
|
|
package/cli.js
CHANGED
|
@@ -269,7 +269,7 @@ Notes:
|
|
|
269
269
|
For advanced dotenv features (multiline, expansion), --require dotenv/config instead.
|
|
270
270
|
- --watch forks a child process running the same CLI without --watch. On file change,
|
|
271
271
|
the child is killed (SIGTERM) and respawned after the debounce delay.
|
|
272
|
-
- In build mode,
|
|
272
|
+
- In build mode, express is always external. Add more externals with --external.
|
|
273
273
|
- In start mode, the bundled handler file must be a JS/CJS module whose "handler"
|
|
274
274
|
export (or default export) is a function: (event, context) => Promise<result>.
|
|
275
275
|
- Init logic for dev mode (DB connections, etc.): add at the top level of your app module.
|
|
@@ -735,12 +735,7 @@ function generateServerlessEntry(appPath, initPath) {
|
|
|
735
735
|
return lines.join("\n") + "\n";
|
|
736
736
|
}
|
|
737
737
|
async function buildServerless(args) {
|
|
738
|
-
|
|
739
|
-
try {
|
|
740
|
-
tsupModule = await import("tsup");
|
|
741
|
-
} catch {
|
|
742
|
-
throw new Error("`tsup` is required for the `build` command. Install it as a dev dependency:\n pnpm add -D tsup");
|
|
743
|
-
}
|
|
738
|
+
const tsupModule = await import("tsup");
|
|
744
739
|
const { build } = tsupModule;
|
|
745
740
|
const entryContent = generateServerlessEntry(args.appPath, args.initPath);
|
|
746
741
|
const tempEntryPath = (0, import_node_path.resolve)(process.cwd(), TEMP_ENTRY_FILENAME);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@web-ts-toolkit/express-runtime",
|
|
3
3
|
"description": "Express app factory plus serverless handler and local dev server helpers",
|
|
4
4
|
"homepage": "https://web-ts-toolkit.pages.dev/docs/packages/express-runtime",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.10.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"keywords": [
|
|
8
8
|
"express",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"node": ">=20"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"serverless-http": "^4.0.0"
|
|
33
|
+
"serverless-http": "^4.0.0",
|
|
34
|
+
"tsup": "^8.5.1"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
37
|
"express": ">=5.0.0"
|