@t8/serve 0.1.27 → 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
@@ -179,13 +179,6 @@ test.beforeAll(async () => {
179
179
  path: "tests/x",
180
180
  bundle: "src/index.tsx",
181
181
  spa: true,
182
- // Optional custom request handler
183
- onRequest(req, res) {
184
- if (req.url === "/items") {
185
- res.writeHead(200, { "content-type": "application/json" });
186
- res.end(JSON.stringify(["apple", "lemon", "cherry"]));
187
- }
188
- }
189
182
  });
190
183
  });
191
184
 
@@ -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.27",
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",