itty-router 4.0.6 → 4.0.7
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 +29 -14
- package/package.json +9 -10
- package/CODE-OF-CONDUCT.md +0 -128
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
<a href="https://npmjs.com/package/itty-router" target="_blank">
|
|
14
14
|
<img src="https://img.shields.io/npm/v/itty-router.svg?style=flat-square" alt="npm version" />
|
|
15
15
|
</a>
|
|
16
|
-
<a href="https://
|
|
17
|
-
<img src="https://
|
|
16
|
+
<a href="https://deno.bundlejs.com/?q=itty-router/Router" target="_blank">
|
|
17
|
+
<img src="https://deno.bundlejs.com/?q=itty-router/Router&badge&badge-style=flat-square" alt="bundle size" />
|
|
18
18
|
</a>
|
|
19
19
|
<a href="https://github.com/kwhitley/itty-router/actions/workflows/verify.yml" target="_blank">
|
|
20
20
|
<img src="https://img.shields.io/github/actions/workflow/status/kwhitley/itty-router/verify.yml?branch=v4.x&style=flat-square" alt="build status" />
|
|
@@ -53,17 +53,33 @@
|
|
|
53
53
|
Itty aims to be the world's smallest (~440 bytes), feature-rich JavaScript router, enabling beautiful API code with a near-zero bundlesize. Designed originally for [Cloudflare Workers](https://itty.dev/itty-router/runtimes#Cloudflare%20Workers), itty can be used in browsers, Service Workers, edge functions, or standalone runtimes like [Node](https://itty.dev/itty-router/runtimes#Node), [Bun](https://itty.dev/itty-router/runtimes#Bun), etc.!
|
|
54
54
|
|
|
55
55
|
## Features:
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
- [
|
|
60
|
-
- [
|
|
61
|
-
- [
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
- Absurdly tiny. The Router itself is ~440 bytes gzipped, and the **entire** library is under 1.5k!
|
|
57
|
+
- Absurdly easy to use. We believe route code should be self-evident, obvious, and read more like poetry than code.
|
|
58
|
+
- Absurdly agnostic. We leave **you** with full control over response types, matching order, upstream/downstream effects, etc.
|
|
59
|
+
- Works [anywhere, in any environment](https://itty.dev/itty-router/runtimes).
|
|
60
|
+
- [Fully typed/TypeScript support](https://itty.dev/itty-router/typescript), including hinting.
|
|
61
|
+
- Parses [route params](https://itty.dev/itty-router/route-patterns#params),
|
|
62
|
+
[optional params](https://itty.dev/itty-router/route-patterns#optional),
|
|
63
|
+
[wildcards](https://itty.dev/itty-router/route-patterns#wildcards),
|
|
64
|
+
[greedy params](https://itty.dev/itty-router/route-patterns#greedy),
|
|
65
|
+
and [file formats](https://itty.dev/itty-router/route-patterns#file-formats).
|
|
66
|
+
- Automatic [query parsing](https://itty.dev/itty-router/route-patterns#query).
|
|
67
|
+
- Easy [error handling](https://itty.dev/itty-router/errors), including throwing errors with HTTP status codes!
|
|
68
|
+
- Easy [Response](https://itty.dev/itty-router/responses) creation, with helpers for major formats (e.g.
|
|
69
|
+
[json](https://itty.dev/itty-router/api#json),
|
|
70
|
+
[html](https://itty.dev/itty-router/api#html),
|
|
71
|
+
[png](https://itty.dev/itty-router/api#png),
|
|
72
|
+
[jpeg](https://itty.dev/itty-router/api#jpeg), etc.)
|
|
73
|
+
- Deep APIs via [router nesting](https://itty.dev/itty-router/nesting).
|
|
74
|
+
- Full [middleware](https://itty.dev/itty-router/middleware) support. Includes the following by default:
|
|
75
|
+
- [withParams](https://itty.dev/itty-router/api#withParams) - access the params directly off the `Request` (instead of `request.params`).
|
|
76
|
+
- [withCookies](https://itty.dev/itty-router/api#withCookies) - access cookies in a convenient Object format.
|
|
77
|
+
- [withContent](https://itty.dev/itty-router/api#withContent) - auto-parse Request bodies as `request.content`.
|
|
78
|
+
- [CORS](https://itty.dev/itty-router/cors) - because we love you.
|
|
79
|
+
- Fully readable regex... yeah right! 😆
|
|
64
80
|
|
|
65
81
|
## [Full Documentation](https://itty.dev/itty-router)
|
|
66
|
-
Complete
|
|
82
|
+
Complete documentation/API is available at [itty.dev](https://itty.dev/itty-router), or join our [Discord](https://discord.com/channels/832353585802903572) channel to chat with community members for quick help!
|
|
67
83
|
|
|
68
84
|
## Installation
|
|
69
85
|
```
|
|
@@ -108,7 +124,7 @@ export default {
|
|
|
108
124
|
```
|
|
109
125
|
|
|
110
126
|
## Join the Discussion!
|
|
111
|
-
Have a question? Suggestion? Complaint? Want to send
|
|
127
|
+
Have a question? Suggestion? Complaint? Want to send a gift basket?
|
|
112
128
|
|
|
113
129
|
Join us on [Discord](https://discord.com/channels/832353585802903572)!
|
|
114
130
|
|
|
@@ -117,9 +133,8 @@ Join us on [Discord](https://discord.com/channels/832353585802903572)!
|
|
|
117
133
|
1. Install dev dependencies via `yarn`
|
|
118
134
|
1. Start test runner/dev mode `yarn dev`
|
|
119
135
|
1. Add your code and tests if needed - do NOT remove/alter existing tests
|
|
120
|
-
1. Verify that tests pass once minified `yarn verify`
|
|
121
136
|
1. Commit files
|
|
122
|
-
1. Submit PR
|
|
137
|
+
1. Submit PR (and fill out the template)
|
|
123
138
|
1. I'll add you to the credits! :)
|
|
124
139
|
|
|
125
140
|
## Special Thanks: Contributors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itty-router",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
4
4
|
"description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -18,17 +18,15 @@
|
|
|
18
18
|
"nested"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
+
"dev": "yarn test",
|
|
21
22
|
"lint": "npx eslint src",
|
|
22
23
|
"test": "vitest --coverage --reporter verbose",
|
|
23
24
|
"test:once": "vitest run",
|
|
24
25
|
"coverage": "vitest run --coverage",
|
|
25
26
|
"coveralls": "yarn coverage && cat ./coverage/lcov.info | coveralls",
|
|
26
27
|
"verify": "echo 'verifying module...' && yarn build && yarn test:once",
|
|
27
|
-
"dev": "yarn test",
|
|
28
28
|
"prerelease": "yarn verify",
|
|
29
|
-
"prebuild": "rimraf dist && mkdir dist",
|
|
30
|
-
"build:core": "rollup -c",
|
|
31
|
-
"build:extras": "rollup --config rollup.config.extras.mjs",
|
|
29
|
+
"prebuild": "rimraf dist && mkdir dist && yarn coverage && yarn lint",
|
|
32
30
|
"build": "rollup -c",
|
|
33
31
|
"release": "release --tag --push --patch --src=dist",
|
|
34
32
|
"runtime:bun": "bun example/bun.ts",
|
|
@@ -51,19 +49,20 @@
|
|
|
51
49
|
"@rollup/plugin-typescript": "^11.1.1",
|
|
52
50
|
"@skypack/package-check": "^0.2.2",
|
|
53
51
|
"@types/node": "^20.2.5",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
|
53
|
+
"@typescript-eslint/parser": "^5.59.8",
|
|
54
54
|
"@vitejs/plugin-vue": "^4.2.3",
|
|
55
|
-
"@vitest/coverage-c8": "^0.31.
|
|
56
|
-
"@whatwg-node/server": "^0.8.
|
|
55
|
+
"@vitest/coverage-c8": "^0.31.3",
|
|
56
|
+
"@whatwg-node/server": "^0.8.1",
|
|
57
57
|
"coveralls": "^3.1.1",
|
|
58
58
|
"eslint": "^8.41.0",
|
|
59
|
-
"eslint-plugin-jest": "^27.2.1",
|
|
60
59
|
"fetch-mock": "^9.11.0",
|
|
61
60
|
"fs-extra": "^11.1.1",
|
|
62
61
|
"globby": "^13.1.4",
|
|
63
62
|
"gzip-size": "^7.0.0",
|
|
64
63
|
"http": "^0.0.1-security",
|
|
65
64
|
"isomorphic-fetch": "^3.0.0",
|
|
66
|
-
"itty-router": "^4.0.
|
|
65
|
+
"itty-router": "^4.0.6",
|
|
67
66
|
"jsdom": "^22.1.0",
|
|
68
67
|
"npm-run-all": "^4.1.5",
|
|
69
68
|
"rimraf": "^5.0.1",
|
|
@@ -74,7 +73,7 @@
|
|
|
74
73
|
"ts-node": "^10.9.1",
|
|
75
74
|
"typescript": "^5.0.4",
|
|
76
75
|
"vite": "^4.3.9",
|
|
77
|
-
"vitest": "^0.31.
|
|
76
|
+
"vitest": "^0.31.3",
|
|
78
77
|
"yarn": "^1.22.19",
|
|
79
78
|
"yarn-release": "^1.10.5"
|
|
80
79
|
}
|
package/CODE-OF-CONDUCT.md
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
-
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
-
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
-
and orientation.
|
|
11
|
-
|
|
12
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
-
diverse, inclusive, and healthy community.
|
|
14
|
-
|
|
15
|
-
## Our Standards
|
|
16
|
-
|
|
17
|
-
Examples of behavior that contributes to a positive environment for our
|
|
18
|
-
community include:
|
|
19
|
-
|
|
20
|
-
* Demonstrating empathy and kindness toward other people
|
|
21
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
-
* Giving and gracefully accepting constructive feedback
|
|
23
|
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
-
and learning from the experience
|
|
25
|
-
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
-
overall community
|
|
27
|
-
|
|
28
|
-
Examples of unacceptable behavior include:
|
|
29
|
-
|
|
30
|
-
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
-
advances of any kind
|
|
32
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
-
* Public or private harassment
|
|
34
|
-
* Publishing others' private information, such as a physical or email
|
|
35
|
-
address, without their explicit permission
|
|
36
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
-
professional setting
|
|
38
|
-
|
|
39
|
-
## Enforcement Responsibilities
|
|
40
|
-
|
|
41
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
-
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
-
or harmful.
|
|
45
|
-
|
|
46
|
-
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
-
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
-
decisions when appropriate.
|
|
50
|
-
|
|
51
|
-
## Scope
|
|
52
|
-
|
|
53
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
-
an individual is officially representing the community in public spaces.
|
|
55
|
-
Examples of representing our community include using an official e-mail address,
|
|
56
|
-
posting via an official social media account, or acting as an appointed
|
|
57
|
-
representative at an online or offline event.
|
|
58
|
-
|
|
59
|
-
## Enforcement
|
|
60
|
-
|
|
61
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
-
reported to the community leaders responsible for enforcement at
|
|
63
|
-
krwhitley@gmail.com.
|
|
64
|
-
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
-
|
|
66
|
-
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
-
reporter of any incident.
|
|
68
|
-
|
|
69
|
-
## Enforcement Guidelines
|
|
70
|
-
|
|
71
|
-
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
-
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
-
|
|
74
|
-
### 1. Correction
|
|
75
|
-
|
|
76
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
-
unprofessional or unwelcome in the community.
|
|
78
|
-
|
|
79
|
-
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
-
clarity around the nature of the violation and an explanation of why the
|
|
81
|
-
behavior was inappropriate. A public apology may be requested.
|
|
82
|
-
|
|
83
|
-
### 2. Warning
|
|
84
|
-
|
|
85
|
-
**Community Impact**: A violation through a single incident or series
|
|
86
|
-
of actions.
|
|
87
|
-
|
|
88
|
-
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
-
interaction with the people involved, including unsolicited interaction with
|
|
90
|
-
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
-
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
-
like social media. Violating these terms may lead to a temporary or
|
|
93
|
-
permanent ban.
|
|
94
|
-
|
|
95
|
-
### 3. Temporary Ban
|
|
96
|
-
|
|
97
|
-
**Community Impact**: A serious violation of community standards, including
|
|
98
|
-
sustained inappropriate behavior.
|
|
99
|
-
|
|
100
|
-
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
-
communication with the community for a specified period of time. No public or
|
|
102
|
-
private interaction with the people involved, including unsolicited interaction
|
|
103
|
-
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
-
Violating these terms may lead to a permanent ban.
|
|
105
|
-
|
|
106
|
-
### 4. Permanent Ban
|
|
107
|
-
|
|
108
|
-
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
-
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
-
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
-
|
|
112
|
-
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
-
the community.
|
|
114
|
-
|
|
115
|
-
## Attribution
|
|
116
|
-
|
|
117
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
-
version 2.0, available at
|
|
119
|
-
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
-
|
|
121
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
-
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
-
|
|
124
|
-
[homepage]: https://www.contributor-covenant.org
|
|
125
|
-
|
|
126
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
-
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
-
https://www.contributor-covenant.org/translations.
|