Compare commits
34
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f200045fd7 | ||
|
|
18d441b3ec | ||
|
|
3714f7befc | ||
|
|
ab58c064d5 | ||
|
|
6fa40672c6 | ||
|
|
1bb82491bd | ||
|
|
b08ecb66cc | ||
|
|
9bff2a52c9 | ||
|
|
551e79a86c | ||
|
|
61bef36d60 | ||
|
|
024b0a79fd | ||
|
|
8c781c1258 | ||
|
|
84a2a29ed6 | ||
|
|
9d8e970c85 | ||
|
|
9e5e5cffe9 | ||
|
|
beec350fcd | ||
|
|
37693246d7 | ||
|
|
1b8f2f3140 | ||
|
|
e820954ea8 | ||
|
|
324ddf0d61 | ||
|
|
f2db461187 | ||
|
|
55263f2d97 | ||
|
|
506dedb624 | ||
|
|
1030109efa | ||
|
|
08d92f5de7 | ||
|
|
8babcb9554 | ||
|
|
6dd23ed874 | ||
|
|
05e59383f1 | ||
|
|
97a146a758 | ||
|
|
aa3402bd84 | ||
|
|
813a29001b | ||
|
|
8d923e053c | ||
|
|
523e302012 | ||
|
|
e068426582 |
No files matched your search
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Something behaves differently from what the docs or the types promise
|
||||||
|
labels: bug
|
||||||
|
---
|
||||||
|
|
||||||
|
## What happened
|
||||||
|
|
||||||
|
## What you expected
|
||||||
|
|
||||||
|
## Minimal reproduction
|
||||||
|
|
||||||
|
The smallest module and route that shows it:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Environment
|
||||||
|
|
||||||
|
- green-tea version:
|
||||||
|
- Runtime and version: <!-- Node 20.11 / Deno 2.1 / Bun 1.1 / Cloudflare Workers -->
|
||||||
|
- OS:
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If it works on one runtime and not another, say which. That difference is
|
||||||
|
usually the bug rather than a detail of it.
|
||||||
|
-->
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Design questions, scope decisions and "should this live in core?" threads don't fit a
|
||||||
|
# bug form, and they are most of what gets filed here. Keep the blank option available.
|
||||||
|
blank_issues_enabled: true
|
||||||
|
|
||||||
|
contact_links:
|
||||||
|
- name: Security vulnerability
|
||||||
|
url: https://github.com/Expressive-Tea/green-tea/security/advisories/new
|
||||||
|
about: Report it privately instead. Never in a public issue — see SECURITY.md.
|
||||||
|
- name: Documentation
|
||||||
|
url: https://green-tea.expressive-tea.io/docs/
|
||||||
|
about: How to wire a route, a module, a plugin or a runtime adapter.
|
||||||
|
- name: Help with your own app
|
||||||
|
url: mailto:support@expressive-tea.io
|
||||||
|
about: Implementation questions about your code rather than a bug in green-tea.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
> **Base branch:** on GitHub this must target `contrib`, not `main`. You can still change it above, before you submit — and [here is why](https://github.com/Expressive-Tea/green-tea/blob/main/CONTRIBUTING.md#where-to-send-your-changes). Delete this line once the base is right.
|
||||||
|
|
||||||
|
## What this changes
|
||||||
|
|
||||||
|
<!-- A sentence or two, on the why rather than the what. -->
|
||||||
|
|
||||||
|
Closes #
|
||||||
|
|
||||||
|
## Checklist
|
||||||
|
|
||||||
|
- [ ] The base branch above is `contrib`
|
||||||
|
- [ ] Commits are signed off (`git commit -s`)
|
||||||
|
- [ ] `npm run lint`, `npm run format:check`, `npm run typecheck`, `npm test`, `npm run complexity:check` and `npm run build` pass locally
|
||||||
|
- [ ] New behavior has a test
|
||||||
|
- [ ] A new public option or method is also declared in `src/app/types.ts`, and noted in `README.md`
|
||||||
|
- [ ] Behavior is the same on Node, Deno and Bun — or the difference is deliberate, and said out loud here
|
||||||
@@ -1,10 +1,40 @@
|
|||||||
name: CI
|
name: CI
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [develop, main]
|
branches: [develop, main, contrib]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [develop, main]
|
branches: [develop, main, contrib]
|
||||||
jobs:
|
jobs:
|
||||||
|
# Separate job so a missing sign-off reports on its own and doesn't hide behind the code
|
||||||
|
# gates, and so it costs nothing on push. Checks that the trailer is present, not that it
|
||||||
|
# matches the author — a mismatch is a judgement call for a reviewer, an absent trailer
|
||||||
|
# is not, and telling a contributor on their first push beats telling them on review.
|
||||||
|
dco:
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Every commit needs a Signed-off-by
|
||||||
|
env:
|
||||||
|
RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
|
||||||
|
run: |
|
||||||
|
missing=0
|
||||||
|
for sha in $(git rev-list --no-merges "$RANGE"); do
|
||||||
|
if ! git show -s --format='%(trailers:key=Signed-off-by,valueonly)' "$sha" | grep -q '[^[:space:]]'; then
|
||||||
|
echo "::error::no Signed-off-by: $(git show -s --format='%h %s' "$sha")"
|
||||||
|
missing=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$missing" = 1 ]; then
|
||||||
|
echo "We use the DCO instead of a CLA. See CONTRIBUTING.md."
|
||||||
|
echo "Fix the whole branch with: git rebase --signoff ${{ github.event.pull_request.base.sha }}"
|
||||||
|
echo "Then: git push --force-with-lease"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "All commits signed off."
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -13,16 +43,23 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: '18'
|
node-version: '18'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm audit
|
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
- run: npm run format:check
|
- run: npm run format:check
|
||||||
- run: npm run complexity:check
|
- run: npm run complexity:check
|
||||||
- run: npm run typecheck
|
- run: npm run typecheck
|
||||||
- run: npm test
|
- run: npm test
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
# Supply chain, deliberately after the code gates: an advisory published by a third party
|
||||||
|
# must never decide whether a contributor gets to see their own lint and typecheck output.
|
||||||
|
# Only what we ship blocks — with `reflect-metadata` as the sole runtime dependency, a
|
||||||
|
# production advisory is rare and genuinely reaches users. Build tooling only reports.
|
||||||
|
- run: npm audit --omit=dev
|
||||||
|
- run: npm audit
|
||||||
|
continue-on-error: true
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '22.12'
|
node-version: '22.12'
|
||||||
- run: npm ci --prefix website
|
- run: npm ci --prefix website
|
||||||
- run: npm audit --prefix website
|
- run: npm audit --prefix website
|
||||||
|
continue-on-error: true
|
||||||
- run: npm run docs:build
|
- run: npm run docs:build
|
||||||
@@ -17,3 +17,10 @@ website/dist/
|
|||||||
|
|
||||||
# Edge (Miniflare) test bundle artifact
|
# Edge (Miniflare) test bundle artifact
|
||||||
test/edge/_worker.mjs
|
test/edge/_worker.mjs
|
||||||
|
|
||||||
|
# Bun writes this on `bun install`, and nothing here consumes it: `npm run test:bun` runs
|
||||||
|
# `bun test` against the node_modules npm installed, which package-lock.json already pins.
|
||||||
|
# deno.lock IS tracked, and that asymmetry is deliberate — the Deno tests import `npm:` and
|
||||||
|
# `jsr:` specifiers that Deno resolves against registries, so only a lockfile makes them
|
||||||
|
# reproducible. Bun resolves the same package.json npm does.
|
||||||
|
bun.lock
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
# AGENTS.md
|
||||||
|
|
||||||
|
Guidance for AI coding assistants working in this repository. Claude Code, Codex, Cursor and anything else that reads this file.
|
||||||
|
|
||||||
|
If you are an assistant: a person reads every line of what you produce before it lands, and the person submitting it signs off on it. Make that reading worth their time — leave the reasoning visible, don't quietly widen the scope you were asked for, and say what you were unsure about instead of smoothing over it. The "Working with AI assistance" section of `CONTRIBUTING.md` applies to your output.
|
||||||
|
|
||||||
|
## What this is
|
||||||
|
|
||||||
|
`@green-tea/core` — a type-safe HTTP framework where the API is a dependency graph rather than a middleware chain. You declare what each step needs and provides; the framework computes execution order, fails at boot if something is missing, and can print the whole pipeline. Runs on Node, Deno, Bun and the edge from one codebase.
|
||||||
|
|
||||||
|
**Hard constraint: one runtime dependency.** `reflect-metadata`, and nothing else. `busboy` and `ws` are peer dependencies. Anything that would add a third belongs in a plugin, not in core.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run lint # eslint
|
||||||
|
npm run format:check # prettier, src/**/*.ts only
|
||||||
|
npm run typecheck # must be clean; includes the compile-time-guarantee type test
|
||||||
|
npm test # vitest
|
||||||
|
npm run build # tsup
|
||||||
|
npm run complexity:check
|
||||||
|
|
||||||
|
npm run test:deno # the other runtimes are NOT covered by `npm test`
|
||||||
|
npm run test:bun
|
||||||
|
npm run test:edge
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the first four before proposing anything as finished. The runtime suites are separate on purpose — a change to shared code that passes `npm test` may still be broken on Deno or Bun.
|
||||||
|
|
||||||
|
## Two forges
|
||||||
|
|
||||||
|
Development lives on a private Gitea instance. GitHub is a downstream mirror that receives `main` and release tags, nothing else.
|
||||||
|
|
||||||
|
```
|
||||||
|
feature/* → develop → main → [promote.yml] → GitHub main
|
||||||
|
↑ ↓
|
||||||
|
lead dev GitHub contrib ← external PRs
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Gitea `develop`** — active development.
|
||||||
|
- **Gitea `main`** — staging. Merging here publishes nothing; only a `v*` tag publishes.
|
||||||
|
- **GitHub `main`** — production mirror. No human touches it. Protected against force-push and deletion, with no review requirement, because `promote.yml` pushes to it directly and a review rule would block that.
|
||||||
|
- **`contrib`** — exists on *both* forges. Where outside contributions land.
|
||||||
|
|
||||||
|
`develop` and `main` on Gitea have direct push disabled with an empty whitelist, so nobody can push to them, admins included. Advance them by opening a PR and merging it.
|
||||||
|
|
||||||
|
## Procedure
|
||||||
|
|
||||||
|
**Promotions are fast-forward-only.** `develop → main` merges with Gitea's fast-forward-only style, so `main` becomes an exact copy of `develop` and no commit is ever born on `main`. This is not a preference: merge-style promotions created seven of the ten commits of drift that had to be cleaned up in August 2026, because each one lived on `main` and never travelled back. Release boundaries are marked by `v*` tags, not by promotion commits.
|
||||||
|
|
||||||
|
**Only `hotfix/*` can still cause real drift**, since it branches from and returns to `main`. That case genuinely needs a back-merge; nothing else does.
|
||||||
|
|
||||||
|
**Diagnosing "this branch is ahead of main".** Usually it is pre-rebase duplication, not unmerged work: the same content under different SHAs, because contributions are rebased on their way into `develop`. Confirm before acting:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git diff <branch> <main> -- <suspect file> # empty means the content is already in main
|
||||||
|
```
|
||||||
|
|
||||||
|
Merging such a branch to "recover" the commits duplicates the work and drags stale history along.
|
||||||
|
|
||||||
|
**External contributions.** They arrive on GitHub `contrib`. Merge the pull request there, mirror that branch to Gitea, then open a `contrib → develop` pull request and merge it. Merge rather than rebase: because promotions are fast-forward-only, `develop` and `main` are the same commit, so there is no main-only history for a merge to drag in. Rebasing would rewrite the contributor's SHAs for no gain and push `contrib` out of `main`'s ancestry, which then costs a force-push at reset time. Merging keeps their commits reaching `main` under their own name and hash.
|
||||||
|
|
||||||
|
The exception is a `hotfix/*`, which lands on `main` without passing through `develop` and leaves the two out of step. Back-merge before taking a contribution through, or rebase that one and accept the force-push. If you do rebase, take the commit range from the pull request itself and never "everything since main": if a second contributor branched from `contrib` after the first one merged, the broad range sweeps up work that isn't theirs.
|
||||||
|
|
||||||
|
**After every promotion, reset *both* `contrib` branches to `main`.** GitHub's is where external work lands; Gitea's is its mirror, and the easy one to forget because nothing there refuses the push. Normally this is an ordinary fast-forward, since `contrib` is already inside `main`'s history. It only needs a force-push when SHAs were rewritten on the way in — and GitHub then refuses it even for admins, so that branch's protection has to be lifted and restored around the reset.
|
||||||
|
|
||||||
|
A conflict against unreleased `develop` work can never be delegated to an outside contributor — they cannot see the code they are conflicting with. Those are always the maintainer's to resolve.
|
||||||
|
|
||||||
|
## CI
|
||||||
|
|
||||||
|
The audit gate is scoped, not severity-filtered: `npm audit --omit=dev` blocks, everything else is `continue-on-error`. A critical in the test runner reaches nobody; a high in `reflect-metadata` reaches everyone. It runs *after* the code gates, because an advisory published by a third party must never decide whether a contributor sees their own lint and typecheck output.
|
||||||
|
|
||||||
|
**The forges disagree about where workflows come from.** GitHub reads `pull_request` workflows from the base branch, so a workflow fix cannot validate itself and must reach the base before it gates anything. Gitea reads from the head. Likewise, `continue-on-error` steps report as `success` on GitHub, hiding the advisory in the log, but as `failure` with the job still green on Gitea.
|
||||||
|
|
||||||
|
GitHub does not run workflows on fork pull requests until a maintainer approves them. A contributor's first push may sit with no checks at all.
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
- Conventional Commits, focused on the *why*. Every commit signed off (`git commit -s`) — the project uses a DCO, and unsigned commits are rejected. No AI co-authoring attribution.
|
||||||
|
- Comments carry reasoning the code cannot show. When editing a block, keep them; if one explains an ordering or a version floor, it is load-bearing.
|
||||||
|
- A new option or method on a public interface has to change `src/app/types.ts` too. An implementation that grows a parameter alone is unreachable for anyone consuming the package.
|
||||||
|
- Behaviour that differs between runtimes must be explicit. An "unavailable here" is fine; silently accepting an option that does nothing is a bug.
|
||||||
|
- New public API needs a note in `README.md`.
|
||||||
@@ -8,6 +8,12 @@ npm treats versions as semver and semver forbids leading zeros.
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `limits.maxConnections` changes Node's previously unlimited concurrent socket count to a
|
||||||
|
default cap of `1000`; values `<= 0` leave Node unlimited. Deno and Bun have no equivalent
|
||||||
|
runtime setting and require a platform or reverse-proxy connection cap.
|
||||||
|
|
||||||
## [26.8.0-beta.0] - 2026-08-02
|
## [26.8.0-beta.0] - 2026-08-02
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
See [AGENTS.md](./AGENTS.md). It is the same guidance, kept in one place so the two files cannot drift apart.
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
|
||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at **compliance@expressive-tea.io**. All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
||||||
|
|
||||||
|
If you would rather write to a named person than to an address, the project lead reads
|
||||||
|
diego.resendez@expressive-tea.io. Reports about a maintainer, including the project lead,
|
||||||
|
should go to compliance@expressive-tea.io, which is not maintained by the project team.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series of actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||||
|
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||||
|
[FAQ]: https://www.contributor-covenant.org/faq
|
||||||
|
[translations]: https://www.contributor-covenant.org/translations
|
||||||
|
|
||||||
+111
-3
@@ -2,6 +2,36 @@
|
|||||||
|
|
||||||
Thanks for your interest. green-tea is open source, but not anyone can push directly — contributions land through reviewed pull/merge requests with a **DCO sign-off**.
|
Thanks for your interest. green-tea is open source, but not anyone can push directly — contributions land through reviewed pull/merge requests with a **DCO sign-off**.
|
||||||
|
|
||||||
|
## Where to send your changes
|
||||||
|
|
||||||
|
Development happens on a private Gitea instance. The GitHub repository is a downstream mirror: it receives `main` and release tags, and nothing else. Which branch you target depends on where you are.
|
||||||
|
|
||||||
|
**From GitHub, if you are an outside contributor:** open your pull request against **`contrib`**. Not `main`. `main` on GitHub is a mirror of released code, and merging into it puts the two forges out of sync and breaks the next release push. A maintainer reviews on `contrib` and then carries your commits upstream into Gitea's `develop`, with your authorship and your sign-off intact.
|
||||||
|
|
||||||
|
**From Gitea, if you have access:** follow the branch model below.
|
||||||
|
|
||||||
|
### Worked example
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# fork Expressive-Tea/green-tea on GitHub, then
|
||||||
|
git clone git@github.com:<you>/green-tea.git
|
||||||
|
cd green-tea
|
||||||
|
git remote add upstream https://github.com/Expressive-Tea/green-tea.git
|
||||||
|
git fetch upstream
|
||||||
|
|
||||||
|
# branch from contrib, not from main
|
||||||
|
git checkout -b fix/close-timeout upstream/contrib
|
||||||
|
|
||||||
|
# ... make the change, add a test ...
|
||||||
|
|
||||||
|
git commit -s -m "fix: add a timeout to app.close()"
|
||||||
|
git push origin fix/close-timeout
|
||||||
|
```
|
||||||
|
|
||||||
|
Then open the pull request with **`contrib`** as the base branch.
|
||||||
|
|
||||||
|
`contrib` tracks released code, so it is reset to `main` after each release. If your branch has been open across one, rebase onto the new `contrib` before pushing again.
|
||||||
|
|
||||||
## Developer Certificate of Origin (DCO)
|
## Developer Certificate of Origin (DCO)
|
||||||
|
|
||||||
We use the [Developer Certificate of Origin](./DCO) instead of a CLA. It's a lightweight, per-commit affirmation that you have the right to submit your work under the project's license. No copyright assignment, no paperwork.
|
We use the [Developer Certificate of Origin](./DCO) instead of a CLA. It's a lightweight, per-commit affirmation that you have the right to submit your work under the project's license. No copyright assignment, no paperwork.
|
||||||
@@ -26,6 +56,34 @@ To sign off a range you forgot to sign:
|
|||||||
git rebase --signoff <base>
|
git rebase --signoff <base>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or, for the commit you just made:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git commit --amend -s
|
||||||
|
git push --force-with-lease
|
||||||
|
```
|
||||||
|
|
||||||
|
## Working with AI assistance
|
||||||
|
|
||||||
|
Use one if it helps. There is no permission to ask for and nothing to declare.
|
||||||
|
|
||||||
|
What we do ask is that you read what it hands you before it becomes a pull request. Every line that lands here is reviewed by a person, by hand, and usually that person is one person. A diff its own author hasn't read moves that work onto them, and turns review into proofreading — which is the thing review is worst at.
|
||||||
|
|
||||||
|
So go through the diff the way you would go through a stranger's, because that is what it is. If you can't say why a line is there, it isn't ready to send. That's the whole of it.
|
||||||
|
|
||||||
|
**What assistants tend to get wrong here in particular** — worth checking before you push:
|
||||||
|
|
||||||
|
- They add dependencies. Core has one runtime dependency, and that is a design constraint rather than an oversight.
|
||||||
|
- They write for Node and assume the rest follows. It doesn't — green-tea also runs on Deno, Bun and the edge, and `npm test` does not cover them.
|
||||||
|
- They delete comments they read as redundant. In this codebase a comment usually carries reasoning the code can't show on its own.
|
||||||
|
- They skip the test.
|
||||||
|
|
||||||
|
**Where you're unsure, say so** — not as a disclosure, as a pointer. "I'm not confident about the Deno path here" tells a reviewer where to spend their attention, and that is worth more to them than a pull request that merely looks clean.
|
||||||
|
|
||||||
|
None of this changes the sign-off. `Signed-off-by` says you have the right to submit the work under this project's license, and that stays true however the text was produced.
|
||||||
|
|
||||||
|
If your assistant reads repository instructions, `AGENTS.md` has the conventions and the architecture notes.
|
||||||
|
|
||||||
## Branch model (GitFlow)
|
## Branch model (GitFlow)
|
||||||
|
|
||||||
- `main` — production-ready, protected. No direct pushes.
|
- `main` — production-ready, protected. No direct pushes.
|
||||||
@@ -33,6 +91,7 @@ git rebase --signoff <base>
|
|||||||
- `feature/<name>` — branch from `develop`.
|
- `feature/<name>` — branch from `develop`.
|
||||||
- `hotfix/<name>` — branch from `main`.
|
- `hotfix/<name>` — branch from `main`.
|
||||||
- `release/<version>` — release stabilization.
|
- `release/<version>` — release stabilization.
|
||||||
|
- `contrib` — GitHub only. Where outside contributions land before a maintainer moves them to `develop`.
|
||||||
|
|
||||||
`main` and `develop` are protected: they require a reviewed MR and signed-off commits. (Branch protection is configured on the git server, not in this repo.)
|
`main` and `develop` are protected: they require a reviewed MR and signed-off commits. (Branch protection is configured on the git server, not in this repo.)
|
||||||
|
|
||||||
@@ -40,17 +99,66 @@ git rebase --signoff <base>
|
|||||||
|
|
||||||
Follow [Conventional Commits](https://www.conventionalcommits.org/): `feat:`, `fix:`, `chore:`, `docs:`, `test:`, `refactor:`. Focus the message on the *why*. Do not add AI co-authoring attribution.
|
Follow [Conventional Commits](https://www.conventionalcommits.org/): `feat:`, `fix:`, `chore:`, `docs:`, `test:`, `refactor:`. Focus the message on the *why*. Do not add AI co-authoring attribution.
|
||||||
|
|
||||||
## Before you open an MR
|
## Local setup
|
||||||
|
|
||||||
|
Node 18 or newer, which is what `engines` requires and what CI runs.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm test # all tests must pass
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
That does one thing worth knowing about: the `prepare` script points `core.hooksPath` at
|
||||||
|
`.githooks/`, which installs a pre-commit gate. The gate formats and lint-fixes your staged
|
||||||
|
sources automatically, then refuses the commit if `npm run lint` or `npm run complexity:check`
|
||||||
|
fails. It is there so CI tells you nothing you couldn't have heard locally. Confirm it took:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git config core.hooksPath # should print .githooks
|
||||||
|
```
|
||||||
|
|
||||||
|
If it prints nothing, run `git config core.hooksPath .githooks` yourself. If you install with
|
||||||
|
something other than npm, check this before your first commit rather than after.
|
||||||
|
|
||||||
|
`npm test` runs the Node suite under Vitest. The other three runtimes have their own commands
|
||||||
|
and their own toolchains, and none of them run in CI:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:deno # needs deno
|
||||||
|
npm run test:bun # needs bun
|
||||||
|
npm run test:edge # Miniflare
|
||||||
|
```
|
||||||
|
|
||||||
|
You are not expected to install all three to fix a typo. You are expected to run the one your
|
||||||
|
change touches, and to say in the pull request which ones you ran.
|
||||||
|
|
||||||
|
## Before you open a pull request
|
||||||
|
|
||||||
|
Run what CI runs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run lint
|
||||||
|
npm run format:check
|
||||||
npm run typecheck # must be clean — this includes the compile-time-guarantee type test
|
npm run typecheck # must be clean — this includes the compile-time-guarantee type test
|
||||||
|
npm test # all tests must pass
|
||||||
|
npm run complexity:check
|
||||||
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
- Write tests for new behavior (TDD welcome). We use Vitest.
|
- Write tests for new behavior (TDD welcome). We use Vitest.
|
||||||
|
- `complexity:check` caps the cognitive complexity of every function in `src/`. What it measures is how much you have to hold in your head to follow a function from top to bottom, and it charges nesting more heavily than branching: a condition inside a closure inside a function costs several times what the same condition costs at the top level. Going over the threshold is not a verdict on your code — it means one function has grown to ask too much of whoever reads it next. The fix is nearly always to lift a nested closure out to module scope, where its branches are charged once instead of three times over. Raising `COMPLEXITY_MAX` is not the fix, even though the script suggests it.
|
||||||
- Keep runtime dependencies at zero beyond `reflect-metadata`.
|
- Keep runtime dependencies at zero beyond `reflect-metadata`.
|
||||||
|
- A new option or method on a public interface has to change that interface too. An implementation that grows a parameter without `src/app/types.ts` growing it as well is unreachable for anyone consuming the package.
|
||||||
- New public API needs a doc note in `README.md`.
|
- New public API needs a doc note in `README.md`.
|
||||||
|
- If your change only works on one runtime, say so in the pull request. green-tea runs on Node, Deno, Bun and the edge, and behavior that quietly differs between them is treated as a bug — an explicit "not available here" is fine, silence is not.
|
||||||
|
|
||||||
|
On GitHub, workflows do not run on pull requests from forks until a maintainer approves them, so your first push may sit without any checks for a while. That is not a rejection.
|
||||||
|
|
||||||
## Reporting issues
|
## Reporting issues
|
||||||
|
|
||||||
Open an issue with a minimal reproduction: green-tea version, Node version, and the smallest module/route that shows the problem.
|
Open an issue with a minimal reproduction: green-tea version, runtime and version, and the smallest module/route that shows the problem.
|
||||||
|
|
||||||
|
**Except for security.** If what you found is exploitable, do not open an issue — an issue is world-readable the moment you press the button. Email security@expressive-tea.io or use the [private advisory form](https://github.com/Expressive-Tea/green-tea/security/advisories/new). [`SECURITY.md`](./SECURITY.md) has the scope and what to expect back.
|
||||||
|
|
||||||
|
## Code of conduct
|
||||||
|
|
||||||
|
By taking part here you agree to the [Code of Conduct](./CODE_OF_CONDUCT.md), which is the Contributor Covenant 2.1. Reports go to compliance@expressive-tea.io.
|
||||||
@@ -109,7 +109,7 @@ Beta shipped the parts a real API needs, without growing the runtime dependency
|
|||||||
- **Real body parsing.** JSON and urlencoded out of the box; `multipart/form-data` file uploads (`@body()` → `{ fields, files }`) via the optional [`busboy`](https://github.com/mscdex/busboy) peer dependency (`npm i busboy`) — a multipart request without it returns a clear `501`. All size-capped (`413`) against DoS.
|
- **Real body parsing.** JSON and urlencoded out of the box; `multipart/form-data` file uploads (`@body()` → `{ fields, files }`) via the optional [`busboy`](https://github.com/mscdex/busboy) peer dependency (`npm i busboy`) — a multipart request without it returns a clear `501`. All size-capped (`413`) against DoS.
|
||||||
- **Errors, your way.** Throw typed errors (`Unauthorized`, `NotFound`, `HttpError(status, msg, body?)`) anywhere; they convert centrally to `4xx`/`5xx`. Render them however you like — HTML, RFC 7807, content-negotiated — with a single `createApp({ onError })` hook that covers every error response.
|
- **Errors, your way.** Throw typed errors (`Unauthorized`, `NotFound`, `HttpError(status, msg, body?)`) anywhere; they convert centrally to `4xx`/`5xx`. Render them however you like — HTML, RFC 7807, content-negotiated — with a single `createApp({ onError })` hook that covers every error response.
|
||||||
- **HTML without a view layer.** `@Html` returns a string, serves a file, or renders one with the built-in `{{ }}` template engine — swap in EJS or handlebars with `createApp({ viewEngine })`. `createApp({ static: true })` serves `./public` with path-traversal guards and no mime dependency.
|
- **HTML without a view layer.** `@Html` returns a string, serves a file, or renders one with the built-in `{{ }}` template engine — swap in EJS or handlebars with `createApp({ viewEngine })`. `createApp({ static: true })` serves `./public` with path-traversal guards and no mime dependency.
|
||||||
- **Ceilings that are already on.** `limits` caps body size (`413`), multipart parts, and the request / headers / keep-alive timeouts — defaulting to `30s` / `10s` / `5s`, tighter than Node's own two-minute default. Configurable, and safe before you configure anything.
|
- **Ceilings that are already on.** `limits` caps body size (`413`), multipart parts, concurrent Node connections (default `1000`; `<= 0` leaves connections unlimited), and the request / headers / keep-alive timeouts — defaulting to `30s` / `10s` / `5s`, tighter than Node's own two-minute default. When Node's connection cap is reached, excess sockets are destroyed without an HTTP response. Deno and Bun expose no equivalent active-socket cap, so enforce one at the deployment platform or reverse proxy there. Configurable, and safe before you configure anything.
|
||||||
- **Graceful shutdown.** `app.close()` drains in-flight requests, closes live streams and mesh links.
|
- **Graceful shutdown.** `app.close()` drains in-flight requests, closes live streams and mesh links.
|
||||||
- **Testable by construction.** `createApp({ overrides: { db: fakeDb } })` swaps any node in one line.
|
- **Testable by construction.** `createApp({ overrides: { db: fakeDb } })` swaps any node in one line.
|
||||||
- **Dual ESM + CommonJS.** Ships both builds behind an `exports` map — `import` and `require` both resolve, with matching type declarations.
|
- **Dual ESM + CommonJS.** Ships both builds behind an `exports` map — `import` and `require` both resolve, with matching type declarations.
|
||||||
|
|||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Reporting a vulnerability
|
||||||
|
|
||||||
|
Email **security@expressive-tea.io**. Please do not open a public issue for something
|
||||||
|
exploitable — an issue is world-readable from the moment you press the button, and that is
|
||||||
|
the one thing a security report cannot be.
|
||||||
|
|
||||||
|
Include whatever you have: the version, the runtime, and the smallest app that shows it.
|
||||||
|
A route, a module and a request is usually enough. If you have a working exploit, send it;
|
||||||
|
if you only have a suspicion, send that instead of sitting on it.
|
||||||
|
|
||||||
|
You can also report privately through GitHub's
|
||||||
|
[security advisory form](https://github.com/Expressive-Tea/green-tea/security/advisories/new),
|
||||||
|
which reaches the same people.
|
||||||
|
|
||||||
|
## What happens next
|
||||||
|
|
||||||
|
Acknowledgement within **5 working days**. A verdict on whether we agree it is a vulnerability
|
||||||
|
within **15**. If we agree, you get the fix timeline and a heads-up before the advisory goes
|
||||||
|
public. If we don't, you get the reasoning rather than silence.
|
||||||
|
|
||||||
|
Those numbers are deliberately slower than the 24 to 48 hours you will see quoted elsewhere.
|
||||||
|
That figure comes from the CERT Guide to Coordinated Vulnerability Disclosure and describes
|
||||||
|
vendors and coordinators — organizations with someone on rotation. This project is one person.
|
||||||
|
A number that only holds in a good week is worse than an honest one.
|
||||||
|
|
||||||
|
Which is why there is an escape hatch, and you should use it. **If you have no acknowledgement
|
||||||
|
after 10 working days**, write directly to diego.resendez@expressive-tea.io. If that is also
|
||||||
|
met with silence, consider yourself released from any embargo and disclose as you see fit. You
|
||||||
|
will not have done anything wrong: a project that goes quiet on a security report has spent
|
||||||
|
whatever claim it had on your patience.
|
||||||
|
|
||||||
|
## Disclosure window
|
||||||
|
|
||||||
|
We ask for **90 days** from your report before public disclosure, or until the fix ships,
|
||||||
|
whichever comes first. That is the industry default and we are not asking you for more than
|
||||||
|
anyone else does. If the fix is out in a week, so is the advisory.
|
||||||
|
|
||||||
|
If a vulnerability is being actively exploited, the window is however long it takes us to ship,
|
||||||
|
and we will say so rather than hold you to 90 days while users are being attacked.
|
||||||
|
|
||||||
|
We publish a GitHub advisory for anything that affects a released version, and credit you by
|
||||||
|
the name you ask for. Say so if you would rather not be named.
|
||||||
|
|
||||||
|
There is no bug bounty and no money, which we would rather state here than leave you to find
|
||||||
|
out after the work.
|
||||||
|
|
||||||
|
## Supported versions
|
||||||
|
|
||||||
|
While the package is in beta, only the most recent `26.x.y-beta.N` receives fixes. There is no
|
||||||
|
backport channel yet; when the first stable ships, this section gets the real table.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
In scope: anything in `src/` that ships in the published package — route matching, the request
|
||||||
|
pipeline, body parsing and its limits, the security headers and CORS handling, TLS setup, the
|
||||||
|
WebSocket upgrade path, the mesh wire protocol, static file serving and view rendering.
|
||||||
|
|
||||||
|
Out of scope: the benchmarks in `bench/`, the docs site in `website/`, dev-only tooling, and
|
||||||
|
anything that requires an attacker to already control your application code. Advisories in
|
||||||
|
build-time dependencies are worth telling us about, but they are not vulnerabilities in
|
||||||
|
green-tea and we handle them as ordinary dependency updates.
|
||||||
|
|
||||||
|
A denial of service that needs no authentication is in scope. Reports that amount to "this
|
||||||
|
endpoint is slow under load" generally are not — but if you are unsure which one you have,
|
||||||
|
send it and let us decide.
|
||||||
+3
-2
@@ -3,13 +3,14 @@
|
|||||||
"version": "26.8.0-beta.0",
|
"version": "26.8.0-beta.0",
|
||||||
"description": "A zen, opinionated, type-safe framework \u2014 your API is a graph, not a middleware chain.",
|
"description": "A zen, opinionated, type-safe framework \u2014 your API is a graph, not a middleware chain.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "green-tea contributors",
|
"author": "green-tea contributors <projects@expressive-tea.io>",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/Expressive-Tea/green-tea.git"
|
"url": "git+https://github.com/Expressive-Tea/green-tea.git"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/Expressive-Tea/green-tea/issues"
|
"url": "https://github.com/Expressive-Tea/green-tea/issues",
|
||||||
|
"email": "projects@expressive-tea.io"
|
||||||
},
|
},
|
||||||
"homepage": "https://green-tea.expressive-tea.io/docs/",
|
"homepage": "https://green-tea.expressive-tea.io/docs/",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ function bunSocket(ws: BunServerWebSocket): WsSocket {
|
|||||||
* Serve a Green Tea app on Bun: HTTP + SSE via app.fetch, WebSocket via Bun's server-level
|
* Serve a Green Tea app on Bun: HTTP + SSE via app.fetch, WebSocket via Bun's server-level
|
||||||
* websocket handler. The ServerWebSocket only exists in open(), so per-connection state
|
* websocket handler. The ServerWebSocket only exists in open(), so per-connection state
|
||||||
* (inbound channel, abort, WsRequest) is stashed on ws.data during the upgrade.
|
* (inbound channel, abort, WsRequest) is stashed on ws.data during the upgrade.
|
||||||
|
* Bun.serve exposes no equivalent to Node's server.maxConnections; enforce connection caps at
|
||||||
|
* the deployment platform or reverse proxy.
|
||||||
*/
|
*/
|
||||||
export function serveBun(app: App, options?: BunServeShortOptions): BunServer {
|
export function serveBun(app: App, options?: BunServeShortOptions): BunServer {
|
||||||
return Bun.serve({
|
return Bun.serve({
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ declare const Deno: {
|
|||||||
/**
|
/**
|
||||||
* Serve a Green Tea app on Deno: HTTP + SSE via app.fetch, WebSocket via Deno.upgradeWebSocket.
|
* Serve a Green Tea app on Deno: HTTP + SSE via app.fetch, WebSocket via Deno.upgradeWebSocket.
|
||||||
* WebSocket messages flow through app.upgrade over the shared neutral core.
|
* WebSocket messages flow through app.upgrade over the shared neutral core.
|
||||||
|
* Deno.serve exposes no equivalent to Node's server.maxConnections; enforce connection caps at
|
||||||
|
* the deployment platform or reverse proxy.
|
||||||
*/
|
*/
|
||||||
export function serveDeno(app: App, options?: DenoServeOptions): DenoHttpServer {
|
export function serveDeno(app: App, options?: DenoServeOptions): DenoHttpServer {
|
||||||
return Deno.serve(options ?? {}, (request, info) => {
|
return Deno.serve(options ?? {}, (request, info) => {
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ export function createHttpServer(
|
|||||||
const server: http.Server = (opts?.tls
|
const server: http.Server = (opts?.tls
|
||||||
? nodeHttps.createServer(opts.tls as https.ServerOptions, handler)
|
? nodeHttps.createServer(opts.tls as https.ServerOptions, handler)
|
||||||
: nodeHttp.createServer(handler)) as unknown as http.Server;
|
: nodeHttp.createServer(handler)) as unknown as http.Server;
|
||||||
|
const maxConnections = opts?.limits?.maxConnections ?? 1000;
|
||||||
|
if (maxConnections > 0) server.maxConnections = maxConnections;
|
||||||
server.requestTimeout = opts?.limits?.requestTimeoutMs ?? 30_000;
|
server.requestTimeout = opts?.limits?.requestTimeoutMs ?? 30_000;
|
||||||
server.headersTimeout = opts?.limits?.headersTimeoutMs ?? 10_000;
|
server.headersTimeout = opts?.limits?.headersTimeoutMs ?? 10_000;
|
||||||
server.keepAliveTimeout = opts?.limits?.keepAliveTimeoutMs ?? 5_000;
|
server.keepAliveTimeout = opts?.limits?.keepAliveTimeoutMs ?? 5_000;
|
||||||
|
|||||||
+2
-1
@@ -5,9 +5,10 @@ import type { TlsOptions, SecurityOptions, CorsOptions } from '../security';
|
|||||||
import type { WsRequest, WsSocket } from './ws-core';
|
import type { WsRequest, WsSocket } from './ws-core';
|
||||||
import type { StaticResolver } from '../views';
|
import type { StaticResolver } from '../views';
|
||||||
|
|
||||||
/** Per-request size and timeout ceilings applied by the server. */
|
/** Per-request and per-server resource ceilings applied by the server. */
|
||||||
export interface RequestLimits {
|
export interface RequestLimits {
|
||||||
maxBodyBytes?: number; // default 1_000_000
|
maxBodyBytes?: number; // default 1_000_000
|
||||||
|
maxConnections?: number; // default 1000; <= 0 means unlimited (Node only)
|
||||||
requestTimeoutMs?: number; // default 30_000
|
requestTimeoutMs?: number; // default 30_000
|
||||||
headersTimeoutMs?: number; // default 10_000
|
headersTimeoutMs?: number; // default 10_000
|
||||||
keepAliveTimeoutMs?: number; // default 5_000
|
keepAliveTimeoutMs?: number; // default 5_000
|
||||||
|
|||||||
+17
-2
@@ -115,15 +115,30 @@ describe('request hardening', () => {
|
|||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets the configured server timeouts', async () => {
|
it('sets the configured server timeouts and connection limit', async () => {
|
||||||
const server = createHttpServer([], [], undefined, undefined,
|
const server = createHttpServer([], [], undefined, undefined,
|
||||||
{ limits: { requestTimeoutMs: 12345, headersTimeoutMs: 6789, keepAliveTimeoutMs: 4321 } });
|
{ limits: { maxConnections: 2468, requestTimeoutMs: 12345, headersTimeoutMs: 6789, keepAliveTimeoutMs: 4321 } });
|
||||||
|
expect(server.maxConnections).toBe(2468);
|
||||||
expect(server.requestTimeout).toBe(12345);
|
expect(server.requestTimeout).toBe(12345);
|
||||||
expect(server.headersTimeout).toBe(6789);
|
expect(server.headersTimeout).toBe(6789);
|
||||||
expect(server.keepAliveTimeout).toBe(4321);
|
expect(server.keepAliveTimeout).toBe(4321);
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('caps concurrent connections by default', () => {
|
||||||
|
const server = createHttpServer([]);
|
||||||
|
expect(server.maxConnections).toBe(1000);
|
||||||
|
server.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([0, -1])('treats maxConnections=%i as unlimited', (maxConnections) => {
|
||||||
|
const server = createHttpServer([], [], undefined, undefined, {
|
||||||
|
limits: { maxConnections },
|
||||||
|
});
|
||||||
|
expect(server.maxConnections).toBeUndefined();
|
||||||
|
server.close();
|
||||||
|
});
|
||||||
|
|
||||||
it('requestTimeout does NOT kill an in-flight SSE stream (streaming regression)', async () => {
|
it('requestTimeout does NOT kill an in-flight SSE stream (streaming regression)', async () => {
|
||||||
async function* feed() { for (let n = 1; n <= 3; n++) { yield { n }; await new Promise((r) => setTimeout(r, 80)); } }
|
async function* feed() { for (let n = 1; n <= 3; n++) { yield { n }; await new Promise((r) => setTimeout(r, 80)); } }
|
||||||
const server = createHttpServer(
|
const server = createHttpServer(
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ interface PackageMetadata {
|
|||||||
};
|
};
|
||||||
readonly bugs?: {
|
readonly bugs?: {
|
||||||
readonly url?: string;
|
readonly url?: string;
|
||||||
|
readonly email?: string;
|
||||||
};
|
};
|
||||||
readonly homepage?: string;
|
readonly homepage?: string;
|
||||||
|
readonly author?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const packageJson = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), 'utf8')) as PackageMetadata;
|
const packageJson = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), 'utf8')) as PackageMetadata;
|
||||||
@@ -27,7 +29,14 @@ describe('package publication metadata', () => {
|
|||||||
it('links npm consumers to support and documentation', () => {
|
it('links npm consumers to support and documentation', () => {
|
||||||
expect(packageJson.bugs).toEqual({
|
expect(packageJson.bugs).toEqual({
|
||||||
url: 'https://github.com/Expressive-Tea/green-tea/issues',
|
url: 'https://github.com/Expressive-Tea/green-tea/issues',
|
||||||
|
email: 'projects@expressive-tea.io',
|
||||||
});
|
});
|
||||||
expect(packageJson.homepage).toBe('https://green-tea.expressive-tea.io/docs/');
|
expect(packageJson.homepage).toBe('https://green-tea.expressive-tea.io/docs/');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// A published package whose only contact is a GitHub URL is unreachable to anyone without
|
||||||
|
// an account, so the address is pinned here rather than left to drift back out.
|
||||||
|
it('gives npm an address to show for the package', () => {
|
||||||
|
expect(packageJson.author).toBe('green-tea contributors <projects@expressive-tea.io>');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -34,6 +34,13 @@ same `@Ws` handlers, same rooms/channels everywhere. `app.listen()`, TLS and per
|
|||||||
remain Node-only; on Deno/Bun/edge you get `app.fetch` + the runtime's adapter. **Mesh (alpha)
|
remain Node-only; on Deno/Bun/edge you get `app.fetch` + the runtime's adapter. **Mesh (alpha)
|
||||||
runs on Node, Deno and Bun** — teapot and teacup, in any combination — but not on edge.
|
runs on Node, Deno and Bun** — teapot and teacup, in any combination — but not on edge.
|
||||||
|
|
||||||
|
**Connection-limit enforcement is Node-only:** `limits.maxConnections` defaults to `1000`; values
|
||||||
|
`<= 0` leave Node's connection count unlimited. Positive values map to Node's
|
||||||
|
`server.maxConnections` when the app runs through `app.listen()`. When the cap is reached, Node
|
||||||
|
destroys excess sockets without sending an HTTP response. `Deno.serve` and `Bun.serve` expose no
|
||||||
|
equivalent active-socket cap, so `serveDeno` and `serveBun` cannot enforce this option. Apply the
|
||||||
|
connection limit at the deployment platform or reverse proxy on those runtimes.
|
||||||
|
|
||||||
**Body-size enforcement differs slightly:** on `app.fetch`, an oversized body is read in full
|
**Body-size enforcement differs slightly:** on `app.fetch`, an oversized body is read in full
|
||||||
before the `413` is returned, whereas Node aborts mid-stream once the limit is hit — so on
|
before the `413` is returned, whereas Node aborts mid-stream once the limit is hit — so on
|
||||||
non-Node runtimes, also bound request size at the platform/runtime layer.
|
non-Node runtimes, also bound request size at the platform/runtime layer.
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ const app = createApp(options);
|
|||||||
| Field | Default |
|
| Field | Default |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `maxBodyBytes` | `1_000_000` (→ `413` when exceeded) |
|
| `maxBodyBytes` | `1_000_000` (→ `413` when exceeded) |
|
||||||
|
| `maxConnections` | `1000` (Node only; `<= 0` means unlimited) |
|
||||||
| `requestTimeoutMs` | `30_000` |
|
| `requestTimeoutMs` | `30_000` |
|
||||||
| `headersTimeoutMs` | `10_000` |
|
| `headersTimeoutMs` | `10_000` |
|
||||||
| `keepAliveTimeoutMs` | `5_000` |
|
| `keepAliveTimeoutMs` | `5_000` |
|
||||||
|
|||||||
Reference in new issue
Block a user