Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Feb 13, 2023
0 parents commit 3b68aba
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
Thumbs.db
npm/
coverage
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"denoland.vscode-deno"
]
}
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"deno.enable": true,
"deno.lint": true,
"deno.codeLens.test": true,
"editor.defaultFormatter": "denoland.vscode-deno",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"deno.inlayHints.enumMemberValues.enabled": false,
"deno.inlayHints.functionLikeReturnTypes.enabled": false,
"deno.inlayHints.parameterTypes.enabled": false,
"deno.inlayHints.propertyDeclarationTypes.enabled": false,
"deno.inlayHints.variableTypes.suppressWhenTypeMatchesName": false,
"deno.inlayHints.variableTypes.enabled": false,
"deno.inlayHints.parameterNames.enabled": "none",
"deno.inlayHints.parameterNames.suppressWhenArgumentMatchesName": false
}
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright (c) 2023 httpland

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# http-middleware

HTTP middleware specification

## What

Define standard HTTP middleware specifications. This is intended to increase the
interoperability of the HTTP library's own middleware.

It consists only of the web standards stack and is compatible with many
Browsers.

## Interface

Middleware interfaces can be defined in TypeScript as follows:

```ts
interface Middleware {
(request: Request, next: Handler): Response | Promise<Response>;
}

interface Handler {
(request: Request): Response | Promise<Response>;
}
```

## Features

`Middleware` has the following features:

- Compatible with `Handler`.

`Handler` is a powerful interface for handling HTTP requests. The `Middleware`
is purely an extension and compatibility with `Handler`.

- It can access to the `Request`.
- It can access the next handler.
- It can call the next handler.
- It can choose not to call the next handler.
- It can access the next handler's return value (`Response`).
- It can return `Response`.

## License

Copyright © 2023-present [httpland](https://github.com/httpland).

Released under the [MIT](./LICENSE) license
27 changes: 27 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"tasks": {
"test": "deno test --doc",
"coverage": "deno coverage",
"build:npm": "deno run -A _tools/build_npm.ts"
},
"fmt": {
"files": {
"exclude": ["CHANGELOG.md", "CODE_OF_CONDUCT.md"]
}
},
"lint": {
"files": {
"exclude": ["CHANGELOG.md", "CODE_OF_CONDUCT.md"]
}
},
"test": {
"files": {
"exclude": ["CHANGELOG.md", "CODE_OF_CONDUCT.md"]
}
},
"compilerOptions": {
"noImplicitReturns": true,
"noImplicitOverride": true,
"noUncheckedIndexedAccess": true
}
}

0 comments on commit 3b68aba

Please sign in to comment.