@zero-server/sdk 0.9.0 → 0.9.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.
- package/README.md +19 -13
- package/lib/body/multipart.js +1 -1
- package/lib/env/index.js +5 -5
- package/lib/middleware/csrf.js +1 -1
- package/lib/middleware/validator.js +1 -1
- package/package.json +5 -5
- package/types/grpc.d.ts +1 -1
- package/types/index.d.ts +2 -2
package/README.md
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="
|
|
2
|
+
<img src="website-docs/public/icons/logo-animated.svg" alt="zero-server logo" width="300" height="300">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<h1 align="center">zero-server</h1>
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@zero-server/sdk"><img src="https://img.shields.io/badge/%40zero--server%2Fsdk-000?style=flat-square&logo=npm&logoColor=white" alt="@zero-server/sdk"></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@zero-server/sdk"><img src="https://img.shields.io/npm/v/%40zero-server%2Fsdk?style=flat-square&logo=npm&logoColor=white&label=&color=00d8e0" alt="npm version"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@zero-server/sdk"><img src="https://img.shields.io/npm/dm/%40zero-server%2Fsdk?style=flat-square&logo=npm&logoColor=white&label=downloads&color=ff6b35" alt="npm downloads"></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://github.com/tonywied17/zero-server/actions"><img src="https://img.shields.io/github/actions/workflow/status/tonywied17/zero-server/ci.yml?branch=main&style=flat-square&logo=githubactions&logoColor=white&label=CI" alt="CI"></a>
|
|
15
|
+
<a href="https://github.com/tonywied17/zero-server/actions"><img src="https://img.shields.io/badge/tests-7385%20passing-brightgreen?style=flat-square&logo=vitest&logoColor=white" alt="tests"></a>
|
|
16
|
+
<a href="https://github.com/tonywied17/zero-server"><img src="https://img.shields.io/badge/coverage-97.01%25-brightgreen?style=flat-square&logo=vitest&logoColor=white" alt="coverage"></a>
|
|
17
|
+
<a href="https://z-server.dev"><img src="https://img.shields.io/badge/docs-z--server.com-00d8e0?style=flat-square&logo=readthedocs&logoColor=white" alt="docs"></a>
|
|
18
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-00d8e0?style=flat-square&logo=opensourceinitiative&logoColor=white" alt="MIT"></a>
|
|
19
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen?style=flat-square&logo=nodedotjs&logoColor=white" alt="node >=18"></a>
|
|
20
|
+
</p>
|
|
15
21
|
|
|
16
22
|
> **Zero-dependency backend framework for Node.js — routing, ORM, auth, WebSocket, SSE, observability, and 20+ middleware from a single `require`.**
|
|
17
23
|
|
|
18
24
|
<p align="center">
|
|
19
25
|
<strong>
|
|
20
|
-
<a href="https://z-server.
|
|
26
|
+
<a href="https://z-server.dev">📖 Full Documentation & Live Playground →</a>
|
|
21
27
|
</strong>
|
|
22
28
|
</p>
|
|
23
29
|
|
|
@@ -384,13 +390,13 @@ const {
|
|
|
384
390
|
|
|
385
391
|
| Resource | Description |
|
|
386
392
|
|---|---|
|
|
387
|
-
| **[z-server.
|
|
393
|
+
| **[z-server.dev](https://z-server.dev)** | Interactive documentation with live playground, search, and examples |
|
|
388
394
|
| **[API.md](API.md)** | Full API reference with tables, examples, and options for every export |
|
|
389
395
|
|
|
390
396
|
### Run docs locally
|
|
391
397
|
|
|
392
398
|
```bash
|
|
393
|
-
cp
|
|
399
|
+
cp website-docs/.env.example website-docs/.env
|
|
394
400
|
npm run docs
|
|
395
401
|
# open http://localhost:7273
|
|
396
402
|
```
|
|
@@ -421,7 +427,7 @@ lib/
|
|
|
421
427
|
sse/ — SSE stream controller
|
|
422
428
|
ws/ — WebSocket connection, handshake, and room management
|
|
423
429
|
types/ — full TypeScript definitions
|
|
424
|
-
|
|
430
|
+
website-docs/ — live demo server, controllers, and playground UI
|
|
425
431
|
test/ — vitest test suite (6000+ tests, 95%+ coverage)
|
|
426
432
|
```
|
|
427
433
|
|
package/lib/body/multipart.js
CHANGED
|
@@ -152,7 +152,7 @@ function multipart(opts = {})
|
|
|
152
152
|
tmpDir = path.isAbsolute(opts.dir) ? opts.dir : path.join(process.cwd(), opts.dir);
|
|
153
153
|
} else
|
|
154
154
|
{
|
|
155
|
-
tmpDir = path.join(os.tmpdir(), 'zero-
|
|
155
|
+
tmpDir = path.join(os.tmpdir(), 'zero-server-uploads');
|
|
156
156
|
}
|
|
157
157
|
const maxFileSize = opts.maxFileSize || null; // bytes
|
|
158
158
|
const maxFields = opts.maxFields !== undefined ? opts.maxFields : 1000;
|
package/lib/env/index.js
CHANGED
|
@@ -223,7 +223,7 @@ let _loaded = false;
|
|
|
223
223
|
* Process environment variables (`process.env`) always take precedence.
|
|
224
224
|
*
|
|
225
225
|
* @param {Object<string, object>} [schema] - Typed schema definition.
|
|
226
|
-
* @param {object} [options] - Configuration options.
|
|
226
|
+
* @param {object} [options] - Configuration options.
|
|
227
227
|
* @param {string} [options.path] - Custom directory to load from (default: `process.cwd()`).
|
|
228
228
|
* @param {boolean} [options.override=false] - When true, overwrite existing `process.env` values with file values.
|
|
229
229
|
* When false (default), file values are written to `process.env` only for keys not already set.
|
|
@@ -399,7 +399,7 @@ function require_(key)
|
|
|
399
399
|
* Check if a variable is set (not undefined).
|
|
400
400
|
*
|
|
401
401
|
* @param {string} key - Variable name.
|
|
402
|
-
* @returns {boolean} Boolean result.
|
|
402
|
+
* @returns {boolean} Boolean result.
|
|
403
403
|
*/
|
|
404
404
|
function has(key)
|
|
405
405
|
{
|
|
@@ -409,7 +409,7 @@ function has(key)
|
|
|
409
409
|
/**
|
|
410
410
|
* Get all loaded values as a plain object.
|
|
411
411
|
*
|
|
412
|
-
* @returns {Object<string, *>} Result value.
|
|
412
|
+
* @returns {Object<string, *>} Result value.
|
|
413
413
|
*/
|
|
414
414
|
function all()
|
|
415
415
|
{
|
|
@@ -433,8 +433,8 @@ function reset()
|
|
|
433
433
|
/**
|
|
434
434
|
* The env function — callable as `env(key)` or `env.key`.
|
|
435
435
|
*
|
|
436
|
-
* @param {string} key - Environment variable name.
|
|
437
|
-
* @returns {*} Result value.
|
|
436
|
+
* @param {string} key - Environment variable name.
|
|
437
|
+
* @returns {*} Result value.
|
|
438
438
|
*/
|
|
439
439
|
function envFn(key)
|
|
440
440
|
{
|
package/lib/middleware/csrf.js
CHANGED
|
@@ -26,7 +26,7 @@ const crypto = require('crypto');
|
|
|
26
26
|
const log = require('../debug')('zero:csrf');
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @param {object} [options] - Configuration options.
|
|
29
|
+
* @param {object} [options] - Configuration options.
|
|
30
30
|
* @param {string} [options.cookie='_csrf'] - Name of the double-submit cookie.
|
|
31
31
|
* @param {string} [options.header='x-csrf-token'] - Request header that carries the token.
|
|
32
32
|
* @param {number} [options.saltLength=18] - Bytes of randomness for token generation.
|
|
@@ -168,7 +168,7 @@ function validateField(value, rule, field)
|
|
|
168
168
|
*
|
|
169
169
|
* @param {object} data - Input data.
|
|
170
170
|
* @param {object} schema - { fieldName: ruleObject }
|
|
171
|
-
* @param {object} [opts] - Configuration options.
|
|
171
|
+
* @param {object} [opts] - Configuration options.
|
|
172
172
|
* @param {boolean} [opts.stripUnknown=true] - Remove fields not in schema.
|
|
173
173
|
* @returns {{ sanitized: object, errors: string[] }}
|
|
174
174
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zero-server/sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Zero-dependency backend framework for Node.js — routing, ORM, auth, WebSocket, SSE, gRPC, observability, and 20+ middleware. Distributed as a single SDK and as scoped @zero-server/* packages.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"LICENSE"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
-
"start": "node
|
|
20
|
-
"docs": "node
|
|
19
|
+
"start": "node website-docs/full-server.js",
|
|
20
|
+
"docs": "node website-docs/full-server.js",
|
|
21
21
|
"test": "vitest run",
|
|
22
22
|
"test:watch": "vitest",
|
|
23
23
|
"test:coverage": "vitest run --coverage",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"jwt",
|
|
44
44
|
"oauth",
|
|
45
45
|
"zero-server",
|
|
46
|
-
"zero-
|
|
46
|
+
"zero-server"
|
|
47
47
|
],
|
|
48
48
|
"author": "Anthony Wiedman",
|
|
49
49
|
"license": "MIT",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"bugs": {
|
|
55
55
|
"url": "https://github.com/tonywied17/zero-server/issues"
|
|
56
56
|
},
|
|
57
|
-
"homepage": "https://z-server.
|
|
57
|
+
"homepage": "https://z-server.dev",
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=18.0.0"
|
|
60
60
|
},
|
package/types/grpc.d.ts
CHANGED
package/types/index.d.ts
CHANGED