Skip to content

Commit 3b68aba

Browse files
committed
chore: initial commit
0 parents  commit 3b68aba

7 files changed

+134
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
Thumbs.db
3+
npm/
4+
coverage

.vscode/extensions.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"denoland.vscode-deno"
4+
]
5+
}

.vscode/settings.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"deno.enable": true,
3+
"deno.lint": true,
4+
"deno.codeLens.test": true,
5+
"editor.defaultFormatter": "denoland.vscode-deno",
6+
"editor.formatOnSave": true,
7+
"editor.codeActionsOnSave": {
8+
"source.fixAll": true
9+
},
10+
"deno.inlayHints.enumMemberValues.enabled": false,
11+
"deno.inlayHints.functionLikeReturnTypes.enabled": false,
12+
"deno.inlayHints.parameterTypes.enabled": false,
13+
"deno.inlayHints.propertyDeclarationTypes.enabled": false,
14+
"deno.inlayHints.variableTypes.suppressWhenTypeMatchesName": false,
15+
"deno.inlayHints.variableTypes.enabled": false,
16+
"deno.inlayHints.parameterNames.enabled": "none",
17+
"deno.inlayHints.parameterNames.suppressWhenArgumentMatchesName": false
18+
}

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
MIT License
2+
3+
Copyright (c) 2023 httpland
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
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, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# http-middleware
2+
3+
HTTP middleware specification
4+
5+
## What
6+
7+
Define standard HTTP middleware specifications. This is intended to increase the
8+
interoperability of the HTTP library's own middleware.
9+
10+
It consists only of the web standards stack and is compatible with many
11+
Browsers.
12+
13+
## Interface
14+
15+
Middleware interfaces can be defined in TypeScript as follows:
16+
17+
```ts
18+
interface Middleware {
19+
(request: Request, next: Handler): Response | Promise<Response>;
20+
}
21+
22+
interface Handler {
23+
(request: Request): Response | Promise<Response>;
24+
}
25+
```
26+
27+
## Features
28+
29+
`Middleware` has the following features:
30+
31+
- Compatible with `Handler`.
32+
33+
`Handler` is a powerful interface for handling HTTP requests. The `Middleware`
34+
is purely an extension and compatibility with `Handler`.
35+
36+
- It can access to the `Request`.
37+
- It can access the next handler.
38+
- It can call the next handler.
39+
- It can choose not to call the next handler.
40+
- It can access the next handler's return value (`Response`).
41+
- It can return `Response`.
42+
43+
## License
44+
45+
Copyright © 2023-present [httpland](https://github.com/httpland).
46+
47+
Released under the [MIT](./LICENSE) license

deno.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"tasks": {
3+
"test": "deno test --doc",
4+
"coverage": "deno coverage",
5+
"build:npm": "deno run -A _tools/build_npm.ts"
6+
},
7+
"fmt": {
8+
"files": {
9+
"exclude": ["CHANGELOG.md", "CODE_OF_CONDUCT.md"]
10+
}
11+
},
12+
"lint": {
13+
"files": {
14+
"exclude": ["CHANGELOG.md", "CODE_OF_CONDUCT.md"]
15+
}
16+
},
17+
"test": {
18+
"files": {
19+
"exclude": ["CHANGELOG.md", "CODE_OF_CONDUCT.md"]
20+
}
21+
},
22+
"compilerOptions": {
23+
"noImplicitReturns": true,
24+
"noImplicitOverride": true,
25+
"noUncheckedIndexedAccess": true
26+
}
27+
}

0 commit comments

Comments
 (0)