@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.
- package/README.md +7 -7
- 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
|
|