@daloyjs/core 0.7.0 → 0.7.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 +42 -31
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# DaloyJS
|
|
2
2
|
|
|
3
|
-
> A **runtime-portable TypeScript web framework** with built-in **contract-first routing**, **validation**, **OpenAPI (Hey API)**, **typed client generation**, **large-scale maintainability**, and **
|
|
3
|
+
> A **runtime-portable TypeScript web framework** with built-in **contract-first routing**, **validation**, **OpenAPI (Hey API)**, **typed client generation**, **large-scale maintainability**, and **security-focused runtime plus supply-chain posture**.
|
|
4
4
|
|
|
5
5
|
DaloyJS is maintained in the GitHub organization at <https://github.com/daloyjs>; the canonical framework repository is <https://github.com/daloyjs/daloy>.
|
|
6
6
|
|
|
7
|
-
📚 **Documentation site:**
|
|
7
|
+
📚 **Documentation site:** <https://daloyjs.dev> — a Next.js 16 + shadcn/ui + Tailwind v4 site with the landing page, getting-started guide, ORM integration guides, tutorials, security docs, and full API reference. Run it with:
|
|
8
8
|
|
|
9
9
|
```zsh
|
|
10
10
|
cd website
|
|
@@ -50,13 +50,27 @@ DaloyJS combines the wins:
|
|
|
50
50
|
1. **Explicit contracts, minimal ceremony.** One `app.route({...})` is the source of truth for validation, types, OpenAPI, the typed client, and contract tests.
|
|
51
51
|
2. **One source of truth for validation, typing, and docs** via [Standard Schema](https://github.com/standard-schema/standard-schema) — Zod 4 / Valibot / ArkType / TypeBox all work, no lock-in.
|
|
52
52
|
3. **Portable core, optional runtime optimizations** — the only thing the core knows is `Request → Response`. Adapters live at the edge.
|
|
53
|
-
4. **
|
|
53
|
+
4. **Security guardrails by default — bad defaults are bugs.** The core enforces body limits, prototype-pollution-safe JSON, path-traversal rejection, request timeouts, content-type checks, and RFC 9457 problem+json errors with prod-mode redaction. First-party middleware covers Helmet-grade headers, CORS, CSRF, rate limits, request ids, and signed-cookie sessions.
|
|
54
54
|
5. **Tooling and inspectability over magic.** `app.introspect()` is a public API; contract-test runner is built in.
|
|
55
55
|
6. **Optimize for large-team maintenance**, not only solo-dev speed. Encapsulated plugins, decorators, request ids, structured logger.
|
|
56
56
|
|
|
57
57
|
---
|
|
58
58
|
|
|
59
|
-
##
|
|
59
|
+
## Get started
|
|
60
|
+
|
|
61
|
+
For a new DaloyJS project, the recommended path is the official scaffolder:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pnpm create daloy@latest my-api
|
|
65
|
+
# or
|
|
66
|
+
npm create daloy@latest my-api
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`create-daloy` gives you a working project structure, runtime template selection, docs routes, OpenAPI wiring, and production-oriented defaults without copying code out of the README.
|
|
70
|
+
|
|
71
|
+
See [Scaffold a project](https://daloyjs.dev/docs/scaffolder) for templates and flags.
|
|
72
|
+
|
|
73
|
+
## Install core manually
|
|
60
74
|
|
|
61
75
|
DaloyJS is distributed via **pnpm** for [supply-chain hygiene](https://pnpm.io/motivation) and backed by a hardened release pipeline — strict isolation, content-addressable store, deterministic lockfile, no phantom dependencies, SHA-pinned CI actions, and provenance publishing.
|
|
62
76
|
|
|
@@ -83,16 +97,6 @@ Run `pnpm audit --prod` regularly (or `pnpm run audit` in this repo) — and `pn
|
|
|
83
97
|
|
|
84
98
|
---
|
|
85
99
|
|
|
86
|
-
## Quick start
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
pnpm create daloy@latest my-api
|
|
90
|
-
# or
|
|
91
|
-
npm create daloy@latest my-api
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
See [Scaffold a project](https://daloyjs.dev/docs/scaffolder) for templates and flags.
|
|
95
|
-
|
|
96
100
|
## Hello world
|
|
97
101
|
|
|
98
102
|
```ts
|
|
@@ -102,7 +106,7 @@ import { serve } from "@daloyjs/core/node";
|
|
|
102
106
|
|
|
103
107
|
const app = new App({ bodyLimitBytes: 1024 * 1024, requestTimeoutMs: 5_000 });
|
|
104
108
|
|
|
105
|
-
//
|
|
109
|
+
// First-party security middleware — usually three plugins in other frameworks.
|
|
106
110
|
app.use(requestId());
|
|
107
111
|
app.use(secureHeaders());
|
|
108
112
|
app.use(rateLimit({ windowMs: 60_000, max: 120 }));
|
|
@@ -177,29 +181,34 @@ import { swaggerUiHtml, htmlResponse } from "@daloyjs/core/docs";
|
|
|
177
181
|
```
|
|
178
182
|
|
|
179
183
|
Mount at `/docs` and the UI is always contract-accurate — never stale.
|
|
180
|
-
`create-daloy@0.1.
|
|
184
|
+
`create-daloy@0.1.20` mounts Swagger UI at `/docs` and the live spec at `/openapi.json` by default.
|
|
181
185
|
|
|
182
186
|
---
|
|
183
187
|
|
|
184
|
-
## Security
|
|
188
|
+
## Security guardrails
|
|
189
|
+
|
|
190
|
+
Some protections are enforced by the `App` core whenever the relevant request
|
|
191
|
+
path is used. Others are first-party middleware so applications can choose the
|
|
192
|
+
right CORS policy, rate-limit key, CSP, session secret, or CSRF rollout for their
|
|
193
|
+
deployment.
|
|
185
194
|
|
|
186
|
-
| Threat |
|
|
195
|
+
| Threat | Built-in behavior |
|
|
187
196
|
|---|---|
|
|
188
|
-
| **Body-size DoS** |
|
|
189
|
-
| **Prototype pollution** |
|
|
190
|
-
| **Header / response splitting** |
|
|
191
|
-
| **Path traversal** |
|
|
192
|
-
| **Slow-loris / hung handlers** | `requestTimeoutMs` aborts handlers (default 30 s); Node adapter sets `requestTimeout` + `headersTimeout` + `maxHeaderSize`. |
|
|
193
|
-
| **MIME sniffing** | `secureHeaders()` sets `X-Content-Type-Options: nosniff
|
|
194
|
-
| **Clickjacking** | `X-Frame-Options: DENY` + CSP `frame-ancestors 'none'
|
|
195
|
-
| **XSS via injected scripts** |
|
|
196
|
-
| **Cross-origin leakage** | `cross-origin-opener-policy` + `cross-origin-resource-policy`
|
|
197
|
+
| **Body-size DoS** | Core-enforced streamed read with a hard cap (default 1 MiB); `Content-Length` checked first. |
|
|
198
|
+
| **Prototype pollution** | Core JSON parser strips `__proto__` / `constructor` / `prototype` via reviver. |
|
|
199
|
+
| **Header / response splitting** | Core header sanitizers reject CRLF + NUL. |
|
|
200
|
+
| **Path traversal** | Core router rejects `..` segments and `//` before walking. |
|
|
201
|
+
| **Slow-loris / hung handlers** | Core `requestTimeoutMs` aborts handlers (default 30 s); Node adapter sets `requestTimeout` + `headersTimeout` + `maxHeaderSize`. |
|
|
202
|
+
| **MIME sniffing** | First-party `secureHeaders()` sets `X-Content-Type-Options: nosniff`; scaffolded apps enable it. |
|
|
203
|
+
| **Clickjacking** | First-party `secureHeaders()` sets `X-Frame-Options: DENY` + CSP `frame-ancestors 'none'`; scaffolded apps enable it. |
|
|
204
|
+
| **XSS via injected scripts** | First-party `secureHeaders()` provides a strict CSP `default-src 'self'` baseline; scaffolded apps enable it. |
|
|
205
|
+
| **Cross-origin leakage** | First-party `secureHeaders()` sets `cross-origin-opener-policy` + `cross-origin-resource-policy` to `same-origin`; scaffolded apps enable it. |
|
|
197
206
|
| **Information disclosure (5xx)** | Production mode strips `detail` from 5xx problem+json automatically. |
|
|
198
|
-
| **Credential timing attacks** | `timingSafeEqual()` for tokens & signatures. |
|
|
199
|
-
| **Brute-force / scraping** | `rateLimit()` with token-bucket + `Retry-After
|
|
207
|
+
| **Credential timing attacks** | First-party `timingSafeEqual()` helper for tokens & signatures. |
|
|
208
|
+
| **Brute-force / scraping** | First-party `rateLimit()` with token-bucket + `Retry-After`; Node/Bun/Deno scaffolded apps enable it. |
|
|
200
209
|
| **Method confusion** | Real **405** with `Allow` header, not a misleading 404. |
|
|
201
|
-
| **CORS misconfig** |
|
|
202
|
-
| **Request correlation** |
|
|
210
|
+
| **CORS misconfig** | First-party `cors()` requires an explicit allowlist and throws for `*` with credentials. |
|
|
211
|
+
| **Request correlation** | First-party `requestId()` uses cryptographic ids; scaffolded apps enable it. |
|
|
203
212
|
| **Supply chain** | pnpm `ignore-scripts=true`, `minimum-release-age=1440`, verified store, reproducible lockfile, lockfile source verification, provenance publishing, and CI/CD hardening against cache poisoning and OIDC token abuse. |
|
|
204
213
|
|
|
205
214
|
The publish pipeline is also hardened: no `pull_request_target`, no GitHub Actions cache in CI, top-level `permissions: {}`, `step-security/harden-runner`, a separate protected `release.yml` workflow, npm trusted publishing with `--provenance`, CodeQL, OpenSSF Scorecard, zizmor workflow linting, Dependabot, and CODEOWNERS on workflow/package files. See [SECURITY.md](SECURITY.md) and the [supply-chain security docs](https://daloyjs.dev/docs/security/supply-chain).
|
|
@@ -333,6 +342,8 @@ WebSockets and HTTP/2 + HTTP/3 adapters.
|
|
|
333
342
|
- [x] `--minimal` flag that strips the bookstore demo and `/docs` + `/openapi.json` routes from any template
|
|
334
343
|
- [x] `daloy inspect` CLI: route table, schema summary, contract-test gate, OpenAPI dump, tag/method filters
|
|
335
344
|
- [x] Redis-backed `RateLimitStore` at `@daloyjs/core/rate-limit-redis` with `ioredisAdapter` / `nodeRedisAdapter` and a fail-open default for shared counters across replicas
|
|
345
|
+
- [x] AI-agent helper files (`AGENTS.md` + `SKILL.md`) shipped in every `create-daloy` template so Copilot/Claude/Cursor/Codex have project context out of the box
|
|
346
|
+
- [x] Polished `create-daloy` terminal UX: DaloyJS welcome banner, arrow-key pickers, install spinner, and boxed next steps while preserving zero runtime dependencies
|
|
336
347
|
|
|
337
348
|
## License
|
|
338
349
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daloyjs/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "DaloyJS is a runtime-portable, contract-first TypeScript web framework with built-in OpenAPI (Hey API), typed client generation, large-scale maintainability, and security-first defaults. Hono-grade portability, Elysia-grade DX, FastAPI-grade docs, Fastify-grade ops — distributed via pnpm.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/daloyjs/daloy.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://daloyjs.dev",
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/daloyjs/daloy/issues"
|
|
16
16
|
},
|