@dim24/servin 0.0.0-stage → 0.2.1

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.
@@ -0,0 +1,43 @@
1
+
2
+ import { serve, param, wire } from "../index.js";
3
+
4
+ const tasksDb = new Map([
5
+ [1, { id: 1, title: "Design domain tree", priority: "high", done: true }],
6
+ [
7
+ 2,
8
+ {
9
+ id: 2,
10
+ title: "Write integration tests",
11
+ priority: "medium",
12
+ done: false,
13
+ },
14
+ ],
15
+ ]);
16
+
17
+ await serve({
18
+ port: 3000,
19
+ api: {
20
+ // GET /health
21
+ health: {
22
+ get: () => ({ status: "ok" }),
23
+ },
24
+
25
+ // GET /tasks?done=false
26
+ tasks: {
27
+ get(query) {
28
+ let list = [...tasksDb.values()];
29
+ if (query.done === "true") list = list.filter((t) => t.done);
30
+ if (query.done === "false") list = list.filter((t) => !t.done);
31
+ return list;
32
+ },
33
+ $id: param('int', {
34
+ // GET /tasks/:id
35
+ get(id) {
36
+ const task = tasksDb.get(id);
37
+ if (!task) wire.abort(404, `Task #${id} not found`);
38
+ return task;
39
+ }
40
+ })
41
+ },
42
+ },
43
+ });
@@ -0,0 +1,11 @@
1
+ export default {
2
+ get() {
3
+ return "Hellow!";
4
+ },
5
+ home: {
6
+ get: () => "this is home",
7
+ $id: {
8
+ get: (id) => "this is id:" + id
9
+ }
10
+ }
11
+ }
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { serve } from './src/server.js';
2
+ export { wire, reactTo } from './src/wire.js';
3
+ export { guard, param, serveStatic, redirect } from './src/tree.js';
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@dim24/servin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.1",
4
+ "description": "A modern, zero-dependency JavaScript web server built around *Domain-Tree Projection.",
5
+ "homepage": "https://github.com/harakun24/servin#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/harakun24/servin/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/harakun24/servin.git"
12
+ },
13
+ "license": "MIT",
14
+ "author": "Abista, V. D.",
15
+ "type": "module",
16
+ "main": "index.js",
17
+ "exports": {
18
+ ".": "./index.js",
19
+ "./test": "./test.js"
20
+ },
21
+ "scripts": {
22
+ "test": "node --test tests/servin.test.js"
23
+ },
24
+ "keywords": [
25
+ "web-server",
26
+ "http-server",
27
+ "web-framework",
28
+ "server",
29
+ "api",
30
+ "nodejs",
31
+ "esm",
32
+ "domain-tree",
33
+ "websocket",
34
+ "sse",
35
+ "server-sent-events",
36
+ "session",
37
+ "caching",
38
+ "virtual-client"
39
+ ]
40
+ }