itty-router 4.0.5 → 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/CONTRIBUTING.md +92 -0
- package/LICENSE +21 -0
- package/README.md +29 -14
- package/package.json +10 -10
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Contributing to Itty
|
|
2
|
+
|
|
3
|
+
The [Open Source Guides](https://opensource.guide/) website has a collection of resources for individuals, communities, and companies. These resources help people who want to learn how to run and contribute to open source projects. Contributors and people new to open source alike will find the following guides especially useful:
|
|
4
|
+
|
|
5
|
+
* [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
|
6
|
+
* [Building Welcoming Communities](https://opensource.guide/building-community/)
|
|
7
|
+
|
|
8
|
+
## Bugs
|
|
9
|
+
|
|
10
|
+
We use [GitHub issues](https://github.com/kwhitley/itty-router/issues) for our public bugs. If you would like to report a problem, take a look around and see if someone already opened an issue about it. If you are certain this is a new unreported bug, you can submit a [bug report](#reporting-new-issues).
|
|
11
|
+
|
|
12
|
+
If you have questions about using itty, [contact us on Discord](https://discord.com/channels/832353585802903572), and we will do our best to answer your questions.
|
|
13
|
+
|
|
14
|
+
### Reporting new issues
|
|
15
|
+
|
|
16
|
+
When [opening a new issue](https://github.com/kwhitley/itty-router/issues/new/choose), always make sure to fill out the issue template. **This step is very important!** Not doing so may result in your issue not being managed in a timely fashion. Don't take this personally if this happens, and feel free to open a new issue once you've gathered all the information required by the template.
|
|
17
|
+
|
|
18
|
+
- **One issue, one bug:** Please report a single bug per issue.
|
|
19
|
+
- **Provide reproduction steps:** List all the steps necessary to reproduce the issue. The person reading your bug report should be able to follow these steps to reproduce your issue with minimal effort.
|
|
20
|
+
|
|
21
|
+
### Proposing a change
|
|
22
|
+
|
|
23
|
+
If you would like to request a new feature or enhancement but are not yet thinking about opening a pull request, you can also file an issue with [feature template](https://github.com/kwhitley/itty-router/issues/new?template=feature_request.yml).
|
|
24
|
+
|
|
25
|
+
If you're only fixing a bug, it's fine to submit a pull request right away, but we still recommend that you file an issue detailing what you're fixing. This is helpful in case we don't accept that specific fix but want to keep track of the issue.
|
|
26
|
+
|
|
27
|
+
Small pull requests are much easier to review and more likely to get merged.
|
|
28
|
+
|
|
29
|
+
### Installation
|
|
30
|
+
|
|
31
|
+
1. Ensure you have [npm](https://www.npmjs.com/get-npm) installed.
|
|
32
|
+
1. Ensure you have [yarn](https://classic.yarnpkg.com/lang/en/docs/install) installed.
|
|
33
|
+
1. After cloning the repository, run `yarn` in the root of the repository.
|
|
34
|
+
1. To start development, run `yarn dev`.
|
|
35
|
+
|
|
36
|
+
### Creating a branch
|
|
37
|
+
|
|
38
|
+
Fork [the repository](https://github.com/kwhitley/itty-router) and create your branch from `v4.x`. If you've never sent a GitHub pull request before, you can learn how from [this free video series](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github).
|
|
39
|
+
|
|
40
|
+
### Testing
|
|
41
|
+
|
|
42
|
+
A good test plan has the exact commands you ran and their output, provides screenshots or videos if the pull request changes UI.
|
|
43
|
+
|
|
44
|
+
- If you've changed APIs, update the documentation, including at the appropriate places within [itty.dev](https://itty.dev/itty-router).
|
|
45
|
+
|
|
46
|
+
#### Writing tests
|
|
47
|
+
|
|
48
|
+
All tests are located in adjacent `.spec.ts` files, next to the file being tested.
|
|
49
|
+
|
|
50
|
+
#### Running tests
|
|
51
|
+
|
|
52
|
+
1. To run test, run `yarn test`, or `yarn dev` for continuous testing (includes `--watch`).
|
|
53
|
+
|
|
54
|
+
### Style guide
|
|
55
|
+
|
|
56
|
+
[Eslint](https://eslint.org) will catch most styling issues that may exist in your code. You can check the status of your code styling by simply running `yarn lint`.
|
|
57
|
+
|
|
58
|
+
#### Code conventions
|
|
59
|
+
|
|
60
|
+
- `camelCase` for public variable names and methods.
|
|
61
|
+
- No abbreviated variable names - maximize readability and let the minification process do its thing later.
|
|
62
|
+
|
|
63
|
+
### Sending your pull request
|
|
64
|
+
|
|
65
|
+
Please make sure the following is done when submitting a pull request:
|
|
66
|
+
|
|
67
|
+
1. Describe your **test plan** in your pull request description. Make sure to test your changes.
|
|
68
|
+
1. Make sure your code lints (`yarn lint`).
|
|
69
|
+
1. Make sure your tests pass (`yarn test`).
|
|
70
|
+
|
|
71
|
+
All pull requests should be opened against the `v4.x` branch. Make sure the PR does only one thing, otherwise please split it.
|
|
72
|
+
|
|
73
|
+
#### Breaking changes
|
|
74
|
+
|
|
75
|
+
When adding a new breaking change, follow this template in your pull request:
|
|
76
|
+
|
|
77
|
+
```md
|
|
78
|
+
### New breaking change here
|
|
79
|
+
|
|
80
|
+
- **Who does this affect**:
|
|
81
|
+
- **How to migrate**:
|
|
82
|
+
- **Why make this breaking change**:
|
|
83
|
+
- **Severity (number of people affected x effort)**:
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
By contributing to itty, you agree that your contributions will be licensed under its [MIT license](https://github.com/kwhitley/itty-router/blob/master/LICENSE).
|
|
89
|
+
|
|
90
|
+
## Questions
|
|
91
|
+
|
|
92
|
+
Feel free to ask in [#itty-router](https://discord.com/channels/832353585802903572) on [Discord](https://discord.com/channels/832353585802903572) if you have questions about our process, how to proceed, etc.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Kevin R. Whitley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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,29 +49,31 @@
|
|
|
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",
|
|
70
69
|
"rollup": "^3.23.0",
|
|
71
70
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
71
|
+
"rollup-plugin-copy": "^3.4.0",
|
|
72
72
|
"rollup-plugin-multi-input": "^1.4.1",
|
|
73
73
|
"ts-node": "^10.9.1",
|
|
74
74
|
"typescript": "^5.0.4",
|
|
75
75
|
"vite": "^4.3.9",
|
|
76
|
-
"vitest": "^0.31.
|
|
76
|
+
"vitest": "^0.31.3",
|
|
77
77
|
"yarn": "^1.22.19",
|
|
78
78
|
"yarn-release": "^1.10.5"
|
|
79
79
|
}
|