Skip to content

Commit

Permalink
feat: use @hapi/hapi in the hapi package
Browse files Browse the repository at this point in the history
BREAKING CHANGE: now requires node >= 12 and newer hapi package @hapi/hapi
  • Loading branch information
makepanic committed Oct 2, 2020
1 parent d066ae8 commit 4ab3dd1
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 55 deletions.
2 changes: 1 addition & 1 deletion packages/hapi/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TPromsterOptions } from '@promster/types';
import type { Server } from 'hapi';
import type { Server } from '@hapi/hapi';

import {
createPlugin,
Expand Down
10 changes: 5 additions & 5 deletions packages/hapi/modules/plugin/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TPromsterOptions, TMetricTypes } from '@promster/types';
import type { TRequestRecorder } from '@promster/metrics';
import type { Plugin, Request, ResponseObject, ResponseToolkit } from 'hapi';
import type Boom from 'boom';
import type { Plugin, Request, ResponseObject, ResponseToolkit } from '@hapi/hapi';
import type { Boom } from '@hapi/boom';

import semver from 'semver';
import merge from 'merge-options';
Expand All @@ -26,10 +26,10 @@ interface TPromsterRequest extends Request {
const extractPath = (request: Request) => request.route.path.replace(/\?/g, '');

/* eslint-disable @typescript-eslint/no-unnecessary-type-arguments */
type TResponse = ResponseObject | Boom<any>;
type TResponse = ResponseObject | Boom;
// eslint-disable-next-line no-undef
const isBoomResponse = (response: TResponse): response is Boom<any> =>
(response as Boom<any>).isBoom;
const isBoomResponse = (response: TResponse): response is Boom =>
(response as Boom).isBoom;
/* eslint-enable @typescript-eslint/no-unnecessary-type-arguments */

const extractStatusCode = (request: Request) => {
Expand Down
8 changes: 4 additions & 4 deletions packages/hapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"access": "public"
},
"engines": {
"node": ">=9",
"npm": ">=3"
"node": ">=12",
"npm": ">=6.9.0"
},
"repository": {
"type": "git",
Expand All @@ -44,8 +44,8 @@
"tslib": "2.0.1"
},
"devDependencies": {
"@hapi/boom": "^9.1.0",
"@promster/types": "^1.0.5",
"@types/boom": "7.3.0",
"@types/hapi": "18.0.3"
"@types/hapi__hapi": "^20.0.1"
}
}
119 changes: 74 additions & 45 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,48 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"

"@hapi/[email protected]":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@hapi/b64/-/b64-5.0.0.tgz#b8210cbd72f4774985e78569b77e97498d24277d"
integrity sha512-ngu0tSEmrezoiIaNGG6rRvKOUkUuDdf4XTPnONHGYfSGRmDqPZX5oJL6HAdKTo1UQHECbdB4OzhWrfgVppjHUw==
dependencies:
"@hapi/hoek" "9.x.x"

"@hapi/[email protected]", "@hapi/boom@^9.0.0", "@hapi/boom@^9.1.0":
version "9.1.0"
resolved "https://registry.yarnpkg.com/@hapi/boom/-/boom-9.1.0.tgz#0d9517657a56ff1e0b42d0aca9da1b37706fec56"
integrity sha512-4nZmpp4tXbm162LaZT45P7F7sgiem8dwAh2vHWT6XX24dozNjGMg6BvKCRvtCUcmcXqeMIUqWN8Rc5X8yKuROQ==
dependencies:
"@hapi/hoek" "9.x.x"

"@hapi/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@hapi/bourne/-/bourne-2.0.0.tgz#5bb2193eb685c0007540ca61d166d4e1edaf918d"
integrity sha512-WEezM1FWztfbzqIUbsDzFRVMxSoLy3HugVcux6KDDtTqzPsLE8NDRHfXvev66aH1i2oOKKar3/XDjbvh/OUBdg==

"@hapi/[email protected]":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@hapi/cryptiles/-/cryptiles-5.1.0.tgz#655de4cbbc052c947f696148c83b187fc2be8f43"
integrity sha512-fo9+d1Ba5/FIoMySfMqPBR/7Pa29J2RsiPrl7bkwo5W5o+AN1dAYQRi4SPrPwwVxVGKjgLOEWrsvt1BonJSfLA==
dependencies:
"@hapi/boom" "9.x.x"

"@hapi/[email protected]":
version "9.1.0"
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.0.tgz#6c9eafc78c1529248f8f4d92b0799a712b6052c6"
integrity sha512-i9YbZPN3QgfighY/1X1Pu118VUz2Fmmhd6b2n0/O8YVgGGfw0FbUYoA97k7FkpGJ+pLCFEDLUmAPPV4D1kpeFw==

"@hapi/iron@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@hapi/iron/-/iron-6.0.0.tgz#ca3f9136cda655bdd6028de0045da0de3d14436f"
integrity sha512-zvGvWDufiTGpTJPG1Y/McN8UqWBu0k/xs/7l++HVU535NLHXsHhy54cfEMdW7EjwKfbBfM9Xy25FmTiobb7Hvw==
dependencies:
"@hapi/b64" "5.x.x"
"@hapi/boom" "9.x.x"
"@hapi/bourne" "2.x.x"
"@hapi/cryptiles" "5.x.x"
"@hapi/hoek" "9.x.x"

"@istanbuljs/load-nyc-config@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
Expand Down Expand Up @@ -944,16 +986,6 @@
"@types/connect" "*"
"@types/node" "*"

"@types/boom@*", "@types/[email protected]":
version "7.3.0"
resolved "https://registry.yarnpkg.com/@types/boom/-/boom-7.3.0.tgz#33280c5552d4cfabc21b8b7e0f6d29292decd985"
integrity sha512-PH7bfkt1nu4pnlxz+Ws+wwJJF1HE12W3ia+Iace2JT7q56DLH3hbyjOJyNHJYRxk3PkKaC36fHfHKyeG1rMgCA==

"@types/catbox@*":
version "10.0.6"
resolved "https://registry.yarnpkg.com/@types/catbox/-/catbox-10.0.6.tgz#8a4c91261cf0afca03351bb82a95b2d6cf43a5d0"
integrity sha512-qS0VHlL6eBUUoUeBnI/ASCffoniS62zdV6IUtLSIjGKmRhZNawotaOMsTYivZOTZVktfe9koAJkD9XFac7tEEg==

"@types/color-name@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
Expand Down Expand Up @@ -992,24 +1024,41 @@
dependencies:
"@types/node" "*"

"@types/[email protected]":
version "18.0.3"
resolved "https://registry.yarnpkg.com/@types/hapi/-/hapi-18.0.3.tgz#e74c019f6a1b1c7f647fe014d3890adec9c0214a"
integrity sha512-UM03myDZ2UWbpqLSZqboK4L98F9r4GCcd9JOr2auhgC3iOd/69mvDggivOHhOYJKWHeCW/dECPHIB7DwQz00dw==
dependencies:
"@types/boom" "*"
"@types/catbox" "*"
"@types/iron" "*"
"@types/hapi__catbox@*":
version "10.2.2"
resolved "https://registry.yarnpkg.com/@types/hapi__catbox/-/hapi__catbox-10.2.2.tgz#b13fbdd6006c8793eb80919158593bc2bf8307c4"
integrity sha512-AWK70LgRsRWL1TNw+aT0IlS56E0pobvFdr/en0K8XazyK4Ey6T/jXhQqv/iQ6FJAAU+somMzgmt9fWq2TaaOkA==

"@types/hapi__hapi@^20.0.1":
version "20.0.1"
resolved "https://registry.yarnpkg.com/@types/hapi__hapi/-/hapi__hapi-20.0.1.tgz#21877f47803ad7b1fae566685b7e67c3dd580a9e"
integrity sha512-PRHXC3Cj1fZsTEX7hK1Fa8ohhhnqvbx1drRlxxgkTJQus0bppZYCPxspstTubv4j1XUDSohmFV9cvvaxN5xbqg==
dependencies:
"@hapi/boom" "^9.0.0"
"@hapi/iron" "^6.0.0"
"@types/hapi__catbox" "*"
"@types/hapi__mimos" "*"
"@types/hapi__podium" "*"
"@types/hapi__shot" "*"
"@types/joi" "*"
"@types/mimos" "*"
"@types/node" "*"
"@types/podium" "*"
"@types/shot" "*"

"@types/iron@*":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@types/iron/-/iron-5.0.1.tgz#5420bbda8623c48ee51b9a78ebad05d7305b4b24"
integrity sha512-Ng5BkVGPt7Tw9k1OJ6qYwuD9+dmnWgActmsnnrdvs4075N8V2go1f6Pz8omG3q5rbHjXN6yzzZDYo3JOgAE/Ug==
"@types/hapi__mimos@*":
version "4.1.2"
resolved "https://registry.yarnpkg.com/@types/hapi__mimos/-/hapi__mimos-4.1.2.tgz#c375e326ca7ec7f65c04d34ae9d253ea2f2a36d7"
integrity sha512-kirHs9NWqucRvHTdeFhglXSxVzeDKD+rUUTAd1/+t4m6lP+hVmu1GWecM1mqE6sg+G9LxFdZaJ+OmFpdhouenA==
dependencies:
"@types/mime-db" "*"

"@types/hapi__podium@*":
version "3.4.0"
resolved "https://registry.yarnpkg.com/@types/hapi__podium/-/hapi__podium-3.4.0.tgz#8efbe18c422e5306a7ee970d48448cf8ff4da37c"
integrity sha512-LE85jLgqR5HscGQ7SaSz6FMRsKlQ1wHVbYc9u0yq7NKDRvZiQFIrr3Pl1RPzK7QNUdZP8zmJibe8q0JcafTAJQ==

"@types/hapi__shot@*":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@types/hapi__shot/-/hapi__shot-4.1.0.tgz#c2f096bf89906e25b530869becca44d40b168b75"
integrity sha512-vIySJYkwIGXMB5eFaZu3U8dS9CAZmteJfmkRn9bYH5uNcSvVgiwDROiwAkD7ej88qA+RZPkUK70KmeDs3LRHvw==
dependencies:
"@types/node" "*"

Expand Down Expand Up @@ -1073,13 +1122,6 @@
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.3.tgz#c893b73721db73699943bfc3653b1deb7faa4a3a"
integrity sha512-Jus9s4CDbqwocc5pOAnh8ShfrnMcPHuJYzVcSUU7lrh8Ni5HuIqX3oilL86p3dlTrk0LzHRCgA/GQ7uNCw6l2Q==

"@types/mimos@*":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@types/mimos/-/mimos-3.0.2.tgz#9595c66ead4e0d1fd022ff5f984851cdd5d5dc7b"
integrity sha512-UG3sdP/9HOk0oA1l8VylaZ0fjy6O/QGEeivOK9JhMjgJkcBJRdfsI6FtXFtg6UH17txmxuDOiIsTlrpBkayK0A==
dependencies:
"@types/mime-db" "*"

"@types/minimist@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
Expand All @@ -1105,11 +1147,6 @@
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==

"@types/podium@*":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/podium/-/podium-1.0.0.tgz#bfaa2151be2b1d6109cc69f7faa9dac2cba3bb20"
integrity sha1-v6ohUb4rHWEJzGn3+qnawsujuyA=

"@types/prettier@^2.0.0":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.1.tgz#be148756d5480a84cde100324c03a86ae5739fb5"
Expand Down Expand Up @@ -1138,13 +1175,6 @@
"@types/express-serve-static-core" "*"
"@types/mime" "*"

"@types/shot@*":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/shot/-/shot-4.0.0.tgz#7545500c489b65c69b5bc5446ba4fef3bd26af92"
integrity sha512-Xv+n8yfccuicMlwBY58K5PVVNtXRm7uDzcwwmCarBxMP+XxGfnh1BI06YiVAsPbTAzcnYsrzpoS5QHeyV7LS8A==
dependencies:
"@types/node" "*"

"@types/stack-utils@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
Expand Down Expand Up @@ -5305,7 +5335,6 @@ prompts@^2.0.1:

"prompts@git://github.com/terkelg/prompts.git#792824f8e5bfe3d632da0e48be23ab718b8f6646":
version "0.1.4"
uid "792824f8e5bfe3d632da0e48be23ab718b8f6646"
resolved "git://github.com/terkelg/prompts.git#792824f8e5bfe3d632da0e48be23ab718b8f6646"
dependencies:
clorox "^1.0.1"
Expand Down

0 comments on commit 4ab3dd1

Please sign in to comment.