@t8/serve 0.1.28 → 0.1.29

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.
Files changed (2) hide show
  1. package/README.md +20 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -111,13 +111,6 @@ let server = await serve({
111
111
  path: "app",
112
112
  bundle: true, // or input path, or `{ input, output, dir }`
113
113
  spa: true,
114
- // Optional custom request handler (e.g. for simple APIs or API mocks)
115
- onRequest(req, res) {
116
- if (req.url === "/items") {
117
- res.writeHead(200, { "content-type": "application/json" });
118
- res.end(JSON.stringify(["apple", "lemon", "cherry"]));
119
- }
120
- },
121
114
  });
122
115
 
123
116
  // Stop
@@ -195,3 +188,23 @@ test.afterAll(() => {
195
188
  ```
196
189
 
197
190
  </details>
191
+
192
+ <details>
193
+ <summary>Example 3 (simple API)</summary>
194
+
195
+ ```ts
196
+ import { serve } from "@t8/serve";
197
+
198
+ let server = await serve({
199
+ // ... Rest of the config
200
+ // Optional custom request handler, e.g. for simple APIs or API mocks
201
+ onRequest(req, res) {
202
+ if (req.url === "/items") {
203
+ res.writeHead(200, { "content-type": "application/json" });
204
+ res.end(JSON.stringify(["apple", "lemon", "cherry"]));
205
+ }
206
+ },
207
+ });
208
+ ```
209
+
210
+ </details>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/serve",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "Simple static file server + bundler, primarily for demo apps and tests, manual or automated",
5
5
  "keywords": [
6
6
  "node",