@t8/serve 0.1.27 → 0.1.28

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 +7 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -111,6 +111,13 @@ 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
+ },
114
121
  });
115
122
 
116
123
  // Stop
@@ -179,13 +186,6 @@ test.beforeAll(async () => {
179
186
  path: "tests/x",
180
187
  bundle: "src/index.tsx",
181
188
  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
189
  });
190
190
  });
191
191
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/serve",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "Simple static file server + bundler, primarily for demo apps and tests, manual or automated",
5
5
  "keywords": [
6
6
  "node",