@t8/serve 0.1.28 → 0.1.30

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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -8
  3. package/package.json +3 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Alexander Tkačenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  Simple static file server + bundler, primarily for demo apps and tests, manual or automated
4
4
 
5
- Use cases:
5
+ ## Use cases
6
+
6
7
  - Use the CLI-based server to launch a demo or test app with a single CLI command.
7
8
  - Use the code-based setup to launch an own server from multiple tests, each with its own app.
8
9
 
@@ -111,13 +112,6 @@ let server = await serve({
111
112
  path: "app",
112
113
  bundle: true, // or input path, or `{ input, output, dir }`
113
114
  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
115
  });
122
116
 
123
117
  // Stop
@@ -195,3 +189,23 @@ test.afterAll(() => {
195
189
  ```
196
190
 
197
191
  </details>
192
+
193
+ <details>
194
+ <summary>Example 3 (simple API)</summary>
195
+
196
+ ```ts
197
+ import { serve } from "@t8/serve";
198
+
199
+ let server = await serve({
200
+ // ... Rest of the config
201
+ // Optional custom request handler, e.g. for simple APIs or API mocks
202
+ onRequest(req, res) {
203
+ if (req.url === "/items") {
204
+ res.writeHead(200, { "content-type": "application/json" });
205
+ res.end(JSON.stringify(["apple", "lemon", "cherry"]));
206
+ }
207
+ },
208
+ });
209
+ ```
210
+
211
+ </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.30",
4
4
  "description": "Simple static file server + bundler, primarily for demo apps and tests, manual or automated",
5
5
  "keywords": [
6
6
  "node",
@@ -14,7 +14,7 @@
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/t8js/serve.git"
16
16
  },
17
- "license": "ISC",
17
+ "license": "MIT",
18
18
  "author": "axtk",
19
19
  "type": "module",
20
20
  "main": "dist/index.js",
@@ -34,6 +34,6 @@
34
34
  "typescript": "^5.9.2"
35
35
  },
36
36
  "dependencies": {
37
- "esbuild": "^0.25.10"
37
+ "esbuild": "^0.25.11"
38
38
  }
39
39
  }