Skip to content

Commit

Permalink
feat(@whook/versions): add the wrapper to check versions
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Jan 3, 2020
1 parent 0d27a8a commit 0034e38
Show file tree
Hide file tree
Showing 17 changed files with 864 additions and 56 deletions.
68 changes: 25 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 118 additions & 0 deletions packages/whook-cors/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/whook-cors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"dependencies": {
"@whook/whook": "^3.1.3",
"@whook/http-router": "^3.1.3",
"@whook/http-transaction": "3.1.3",
"knifecycle": "^8.0.1",
"openapi-types": "^1.3.5",
"swagger-parser": "^8.0.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/whook-cors/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export declare type CORSConfig = {
*/
export declare function wrapHandlerWithCORS<D, S extends WhookHandler>(
initHandler: ServiceInitializer<D, S>,
): ServiceInitializer<D, S>;
): ServiceInitializer<D & CORSConfig, S>;
export declare function initHandlerWithCORS<D, S extends WhookHandler>(
initHandler: ServiceInitializer<D, S>,
services: D,
Expand Down
7 changes: 3 additions & 4 deletions packages/whook-cors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type CORSConfig = {
*/
export function wrapHandlerWithCORS<D, S extends WhookHandler>(
initHandler: ServiceInitializer<D, S>,
): ServiceInitializer<D, S> {
): ServiceInitializer<D & CORSConfig, S> {
return alsoInject(
['CORS'],
reuseSpecialProps(initHandler, initHandlerWithCORS.bind(null, initHandler)),
Expand Down Expand Up @@ -82,9 +82,8 @@ export async function augmentAPIWithCORS(
API: OpenAPIV3.Document,
): Promise<OpenAPIV3.Document> {
const $refs = await OpenAPIParser.resolve(API);
const flattenedAPI: OpenAPIV3.Document = API;

return Object.keys(flattenedAPI.paths).reduce((newAPI, path) => {
return Object.keys(API.paths).reduce((newAPI, path) => {
const existingOperation = newAPI.paths[path].options;

if (existingOperation) {
Expand Down Expand Up @@ -163,7 +162,7 @@ export async function augmentAPIWithCORS(
};

return newAPI;
}, flattenedAPI);
}, API);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions packages/whook-method-override/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@
},
"homepage": "https://github.com/nfroidure/whook",
"dependencies": {
"@whook/whook": "^3.1.3",
"@whook/http-transaction": "^3.1.3",
"common-services": "^6.1.0",
"knifecycle": "^8.0.1"
},
"peerDependencies": {
"@whook/whook": "^3.1.3"
},
"devDependencies": {
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
Expand All @@ -60,7 +58,6 @@
"@babel/register": "^7.7.4",
"@types/jest": "^24.0.23",
"@typescript-eslint/parser": "^2.9.0",
"@whook/http-transaction": "^3.1.3",
"@whook/whook": "^3.1.3",
"babel-eslint": "^10.0.3",
"babel-plugin-knifecycle": "^1.1.1",
Expand Down
20 changes: 20 additions & 0 deletions packages/whook-versions/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright © 2017 Nicolas Froidure

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.
25 changes: 25 additions & 0 deletions packages/whook-versions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[//]: # ( )
[//]: # (This file is automatically generated by a `metapak`)
[//]: # (module. Do not change it except between the)
[//]: # (`content:start/end` flags, your changes would)
[//]: # (be overridden.)
[//]: # ( )
# @whook/versions
> A wrapper to provide versions check support to a Whook server
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/whook/blob/master/packages/whook-versions/LICENSE)
[![NPM version](https://badge.fury.io/js/%40whook%2Fversions.svg)](https://npmjs.org/package/@whook/versions)


[//]: # (::contents:start)

This wrapper simply answer to any HTTP call with a unsupported
version header with a 418 HTTP error.

[//]: # (::contents:end)

# Authors
- [Nicolas Froidure](http://insertafter.com/en/index.html)

# License
[MIT](https://github.com/nfroidure/whook/blob/master/packages/whook-versions/LICENSE)
Loading

0 comments on commit 0034e38

Please sign in to comment.