@lidofinance/next-api-wrapper 0.18.0 → 0.20.0

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/README.md CHANGED
@@ -98,3 +98,27 @@ const someRequest: API = async (req, res) => await fetch()
98
98
 
99
99
  export default defaultErrorAndCacheWrapper(someRequest)
100
100
  ```
101
+
102
+ ### Response time metric
103
+
104
+ ```ts
105
+ import { wrapRequest, responseTimeMetric } from '@lidofinance/next-api-wrapper'
106
+ import { NextApiRequest, NextApiResponse } from 'next'
107
+ import { Registry, Histogram } from 'prom-client'
108
+
109
+ export type API = (req: NextApiRequest, res: NextApiResponse) => Promise<void>
110
+
111
+ const apiTimings = new Histogram({
112
+ name: 'frontend_template_api_response_internal',
113
+ help: 'API response time',
114
+ labelNames: ['hostname', 'route', 'entity', 'status'],
115
+ buckets: [0.1, 0.2, 0.3, 0.6, 1, 1.5, 2, 5],
116
+ registers: new Registry(),
117
+ });
118
+
119
+ const someRequest: API = async (req, res) => await fetch()
120
+
121
+ export default wrapRequest([
122
+ responseTimeMetric(apiTimings, 'api/some-request'),
123
+ ])(someRequest)
124
+ ```
package/dist/index.cjs CHANGED
@@ -1,3 +1,5 @@
1
+ var $93IVf$lidofinanceapimetrics = require("@lidofinance/api-metrics");
2
+
1
3
  function $parcel$exportWildcard(dest, source) {
2
4
  Object.keys(source).forEach(function(key) {
3
5
  if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
@@ -27,6 +29,8 @@ var $d48d8f2703fa966d$exports = {};
27
29
 
28
30
  $parcel$export($d48d8f2703fa966d$exports, "defaultErrorHandler", function () { return $d48d8f2703fa966d$export$74226d5f34b9550e; });
29
31
  $parcel$export($d48d8f2703fa966d$exports, "cacheControl", function () { return $d48d8f2703fa966d$export$935bfe081ea97cf4; });
32
+ $parcel$export($d48d8f2703fa966d$exports, "responseTimeMetric", function () { return $d48d8f2703fa966d$export$156cbc8f54439240; });
33
+
30
34
  var $b042f7e98544cfc1$exports = {};
31
35
 
32
36
  $parcel$export($b042f7e98544cfc1$exports, "DEFAULT_API_ERROR_MESSAGE", function () { return $b042f7e98544cfc1$export$c982278a0ddc4dbe; });
@@ -45,6 +49,10 @@ const $ff2b7f149731334e$export$8cc545829c7461b0 = (error, defaultMessage)=>{
45
49
  };
46
50
 
47
51
 
52
+ const $d48d8f2703fa966d$var$isErrorWithStatus = (error)=>{
53
+ if (typeof error !== "object" || error === null) return false;
54
+ return "status" in error;
55
+ };
48
56
  const $d48d8f2703fa966d$export$74226d5f34b9550e = (args)=>{
49
57
  return async (req, res, next)=>{
50
58
  const { errorMessage: errorMessage = (0, $b042f7e98544cfc1$export$c982278a0ddc4dbe) , serverLogger: serverLogger } = args || {};
@@ -53,7 +61,12 @@ const $d48d8f2703fa966d$export$74226d5f34b9550e = (args)=>{
53
61
  } catch (error) {
54
62
  const isInnerError = res.statusCode === 200;
55
63
  const status = isInnerError ? 500 : res.statusCode || 500;
56
- if (error instanceof Error) {
64
+ if ($d48d8f2703fa966d$var$isErrorWithStatus(error)) {
65
+ serverLogger === null || serverLogger === void 0 ? void 0 : serverLogger.error((0, $ff2b7f149731334e$export$8cc545829c7461b0)(error, errorMessage));
66
+ res.status(error.status).json({
67
+ message: (0, $ff2b7f149731334e$export$8cc545829c7461b0)(error, errorMessage)
68
+ });
69
+ } else if (error instanceof Error) {
57
70
  serverLogger === null || serverLogger === void 0 ? void 0 : serverLogger.error((0, $ff2b7f149731334e$export$8cc545829c7461b0)(error, errorMessage));
58
71
  res.status(status).json({
59
72
  message: (0, $ff2b7f149731334e$export$8cc545829c7461b0)(error, errorMessage)
@@ -79,6 +92,26 @@ const $d48d8f2703fa966d$export$935bfe081ea97cf4 = (args)=>{
79
92
  }
80
93
  };
81
94
  };
95
+ const $d48d8f2703fa966d$export$156cbc8f54439240 = (metrics, route)=>{
96
+ return async (req, res, next)=>{
97
+ let status = "2xx";
98
+ const endMetric = metrics.startTimer({
99
+ route: route
100
+ });
101
+ try {
102
+ await (next === null || next === void 0 ? void 0 : next(req, res, next));
103
+ status = (0, $93IVf$lidofinanceapimetrics.getStatusLabel)(res.statusCode);
104
+ } catch (error) {
105
+ status = (0, $93IVf$lidofinanceapimetrics.getStatusLabel)(res.statusCode);
106
+ // throw error up the stack
107
+ throw error;
108
+ } finally{
109
+ endMetric({
110
+ status: status
111
+ });
112
+ }
113
+ };
114
+ };
82
115
 
83
116
 
84
117
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;ACEO,MAAM,4CACX,CAAW,WACX,CAAC,iBACC,SAAS,MAAM,CAAC,CAAC,KAAK,MAAQ,CAAC,KAAK,MAAQ,IAAI,KAAK,KAAK,IAAM,IAAI,KAAK,OAAO;;ADLpF;;;;;;;;;;AGAO,MAAM,4CAA4B;AAElC,MAAM,4CAAwB;AAC9B,MAAM,4CAA8B;;ADH3C;AEAA;AAEO,MAAM,4CAAsB,CAAC,OAAgB,iBAAoC;IACtF,IAAI,OAAO,UAAU,UAAU,OAAO;IACtC,IAAI,iBAAiB,OAAO,OAAO,MAAM,OAAO;IAChD,OAAO,2BAAA,4BAAA,iBAAkB,CAAA,GAAA,yCAAwB,CAAC;AACpD;;;AFDO,MAAM,4CACX,CAAC;IACD,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,MAAM,gBAAE,eAAe,CAAA,GAAA,yCAAwB,kBAAG,aAAY,EAAE,GAAG,QAAQ,CAAC;QAC5E,IAAI;YACF,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;QACzB,EAAE,OAAO,OAAO;YACd,MAAM,eAAe,IAAI,UAAU,KAAK;YACxC,MAAM,SAAS,eAAe,MAAM,IAAI,UAAU,IAAI,GAAG;YAEzD,IAAI,iBAAiB,OAAO;gBAC1B,yBAAA,0BAAA,KAAA,IAAA,aAAc,KAAK,CAAC,CAAA,GAAA,yCAAkB,EAAE,OAAO;gBAC/C,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;oBAAE,SAAS,CAAA,GAAA,yCAAmB,AAAD,EAAE,OAAO;gBAAc;YAC9E,OACE,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;gBAAE,SAAS;YAAa;QAEpD;IACF;;AAEK,MAAM,4CACX,CAAC;IACD,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,MAAM,WAAE,UAAU,CAAA,GAAA,yCAAoB,kBAAG,eAAe,CAAA,GAAA,yCAA2B,AAAD,IAAG,GAAG,QAAQ,CAAC;QACjG,IAAI;YACF,IAAI,SAAS,CAAC,iBAAiB;YAE/B,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;QACzB,EAAE,OAAO,OAAO;YACd,0CAA0C;YAC1C,sDAAsD;YACtD,IAAI,SAAS,CAAC,iBAAiB;YAE/B,2BAA2B;YAC3B,MAAM,MAAK;QACb;IACF;;;;;;;","sources":["packages/next/api-wrapper/src/index.ts","packages/next/api-wrapper/src/wrapRequest.ts","packages/next/api-wrapper/src/wrappers.ts","packages/next/api-wrapper/src/constants.ts","packages/next/api-wrapper/src/utils.ts","packages/next/api-wrapper/src/types.ts"],"sourcesContent":["export * from './wrapRequest'\nexport * from './wrappers'\nexport * from './constants'\nexport * from './types'\n","import { RequestWrapper, API } from './types'\n\nexport const wrapRequest =\n <T = void>(wrappers: RequestWrapper<T>[]) =>\n (requestHandler: API<T>) =>\n wrappers.reduce((acc, cur) => (req, res) => cur(req, res, () => acc(req, res)), requestHandler)\n","import { DEFAULT_API_ERROR_MESSAGE, CACHE_DEFAULT_ERROR_HEADERS, CACHE_DEFAULT_HEADERS } from './constants'\nimport { extractErrorMessage } from './utils'\nimport { RequestWrapper, DefaultErrorHandlerArgs, CacheControlArgs } from './types'\n\n// must be last in the wrapper stack\nexport const defaultErrorHandler =\n (args?: DefaultErrorHandlerArgs): RequestWrapper =>\n async (req, res, next) => {\n const { errorMessage = DEFAULT_API_ERROR_MESSAGE, serverLogger } = args || {}\n try {\n await next?.(req, res, next)\n } catch (error) {\n const isInnerError = res.statusCode === 200\n const status = isInnerError ? 500 : res.statusCode || 500\n\n if (error instanceof Error) {\n serverLogger?.error(extractErrorMessage(error, errorMessage))\n res.status(status).json({ message: extractErrorMessage(error, errorMessage) })\n } else {\n res.status(status).json({ message: errorMessage })\n }\n }\n }\n\nexport const cacheControl =\n (args?: CacheControlArgs): RequestWrapper =>\n async (req, res, next) => {\n const { headers = CACHE_DEFAULT_HEADERS, errorHeaders = CACHE_DEFAULT_ERROR_HEADERS } = args || {}\n try {\n res.setHeader('Cache-Control', headers)\n\n await next?.(req, res, next)\n } catch (error) {\n // for requests with cache-control headers\n // need set new headers otherwise error will be cached\n res.setHeader('Cache-Control', errorHeaders)\n\n // throw error up the stack\n throw error\n }\n }\n","export const DEFAULT_API_ERROR_MESSAGE = 'Something went wrong.'\n\nexport const CACHE_DEFAULT_HEADERS = 'public, max-age=180, stale-if-error=1200, stale-while-revalidate=60'\nexport const CACHE_DEFAULT_ERROR_HEADERS = 'no-store, must-revalidate'\n","import { DEFAULT_API_ERROR_MESSAGE } from './constants'\n\nexport const extractErrorMessage = (error: unknown, defaultMessage?: string): string => {\n if (typeof error === 'string') return error\n if (error instanceof Error) return error.message\n return defaultMessage ?? DEFAULT_API_ERROR_MESSAGE\n}\n","import { NextApiResponse, NextApiRequest } from 'next'\nimport { ServerLogger } from '@lidofinance/api-logger'\n\nexport type API<T = void> = (req: NextApiRequest, res: NextApiResponse) => Promise<T> | T\n\nexport type RequestWrapper<T = void> = (\n req: NextApiRequest,\n res: NextApiResponse,\n next?: API<T> | RequestWrapper<T>,\n) => Promise<T> | T\n\nexport type MixedWrapper = <T = void>(api: API<T>) => RequestWrapper<T>\n\nexport type DefaultErrorHandlerArgs = {\n errorMessage?: string\n serverLogger?: ServerLogger\n}\n\nexport type CacheControlArgs = {\n headers?: string\n errorHeaders?: string\n}\n"],"names":[],"version":3,"file":"index.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;ACEO,MAAM,4CACX,CAAW,WACX,CAAC,iBACC,SAAS,MAAM,CAAC,CAAC,KAAK,MAAQ,CAAC,KAAK,MAAQ,IAAI,KAAK,KAAK,IAAM,IAAI,KAAK,OAAO;;ADLpF;;;;;;AEAA;;;;;;ACAO,MAAM,4CAA4B;AAElC,MAAM,4CAAwB;AAC9B,MAAM,4CAA8B;;;ACH3C;AAEO,MAAM,4CAAsB,CAAC,OAAgB,iBAAoC;IACtF,IAAI,OAAO,UAAU,UAAU,OAAO;IACtC,IAAI,iBAAiB,OAAO,OAAO,MAAM,OAAO;IAChD,OAAO,2BAAA,4BAAA,iBAAkB,CAAA,GAAA,yCAAwB,CAAC;AACpD;;;AFGA,MAAM,0CAAoB,CAAC,QAA6C;IACtE,IAAI,OAAO,UAAU,YAAY,UAAU,IAAI,EAAE,OAAO,KAAK;IAC7D,OAAO,YAAY;AACrB;AAGO,MAAM,4CACX,CAAC;IACD,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,MAAM,gBAAE,eAAe,CAAA,GAAA,yCAAwB,kBAAG,aAAY,EAAE,GAAG,QAAQ,CAAC;QAC5E,IAAI;YACF,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;QACzB,EAAE,OAAO,OAAO;YACd,MAAM,eAAe,IAAI,UAAU,KAAK;YACxC,MAAM,SAAS,eAAe,MAAM,IAAI,UAAU,IAAI,GAAG;YAEzD,IAAI,wCAAkB,QAAQ;gBAC5B,yBAAA,0BAAA,KAAA,IAAA,aAAc,KAAK,CAAC,CAAA,GAAA,yCAAkB,EAAE,OAAO;gBAC/C,IAAI,MAAM,CAAC,MAAM,MAAM,EAAE,IAAI,CAAC;oBAAE,SAAS,CAAA,GAAA,yCAAmB,AAAD,EAAE,OAAO;gBAAc;YACpF,OAAO,IAAI,iBAAiB,OAAO;gBACjC,yBAAA,0BAAA,KAAA,IAAA,aAAc,KAAK,CAAC,CAAA,GAAA,yCAAkB,EAAE,OAAO;gBAC/C,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;oBAAE,SAAS,CAAA,GAAA,yCAAmB,AAAD,EAAE,OAAO;gBAAc;YAC9E,OACE,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;gBAAE,SAAS;YAAa;QAEpD;IACF;;AAEK,MAAM,4CACX,CAAC;IACD,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,MAAM,WAAE,UAAU,CAAA,GAAA,yCAAoB,kBAAG,eAAe,CAAA,GAAA,yCAA2B,AAAD,IAAG,GAAG,QAAQ,CAAC;QACjG,IAAI;YACF,IAAI,SAAS,CAAC,iBAAiB;YAE/B,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;QACzB,EAAE,OAAO,OAAO;YACd,0CAA0C;YAC1C,sDAAsD;YACtD,IAAI,SAAS,CAAC,iBAAiB;YAE/B,2BAA2B;YAC3B,MAAM,MAAK;QACb;IACF;;AAEK,MAAM,4CACX,CAAC,SAA4B;IAC7B,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,IAAI,SAAS;QACb,MAAM,YAAY,QAAQ,UAAU,CAAC;mBAAE;QAAM;QAE7C,IAAI;YACF,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;YACvB,SAAS,CAAA,GAAA,2CAAc,AAAD,EAAE,IAAI,UAAU;QACxC,EAAE,OAAO,OAAO;YACd,SAAS,CAAA,GAAA,2CAAc,AAAD,EAAE,IAAI,UAAU;YACtC,2BAA2B;YAC3B,MAAM,MAAK;QACb,SAAU;YACR,UAAU;wBAAE;YAAO;QACrB;IACF;;;;;;;","sources":["packages/next/api-wrapper/src/index.ts","packages/next/api-wrapper/src/wrapRequest.ts","packages/next/api-wrapper/src/wrappers.ts","packages/next/api-wrapper/src/constants.ts","packages/next/api-wrapper/src/utils.ts","packages/next/api-wrapper/src/types.ts"],"sourcesContent":["export * from './wrapRequest'\nexport * from './wrappers'\nexport * from './constants'\nexport * from './types'\n","import { RequestWrapper, API } from './types'\n\nexport const wrapRequest =\n <T = void>(wrappers: RequestWrapper<T>[]) =>\n (requestHandler: API<T>) =>\n wrappers.reduce((acc, cur) => (req, res) => cur(req, res, () => acc(req, res)), requestHandler)\n","import { Histogram } from 'prom-client'\nimport { getStatusLabel } from '@lidofinance/api-metrics'\n\nimport { DEFAULT_API_ERROR_MESSAGE, CACHE_DEFAULT_ERROR_HEADERS, CACHE_DEFAULT_HEADERS } from './constants'\nimport { extractErrorMessage } from './utils'\nimport { RequestWrapper, DefaultErrorHandlerArgs, CacheControlArgs } from './types'\n\ntype ErrorWithStatus = Error & { status: number }\n\nconst isErrorWithStatus = (error: unknown): error is ErrorWithStatus => {\n if (typeof error !== 'object' || error === null) return false\n return 'status' in error\n}\n\n// must be last in the wrapper stack\nexport const defaultErrorHandler =\n (args?: DefaultErrorHandlerArgs): RequestWrapper =>\n async (req, res, next) => {\n const { errorMessage = DEFAULT_API_ERROR_MESSAGE, serverLogger } = args || {}\n try {\n await next?.(req, res, next)\n } catch (error) {\n const isInnerError = res.statusCode === 200\n const status = isInnerError ? 500 : res.statusCode || 500\n\n if (isErrorWithStatus(error)) {\n serverLogger?.error(extractErrorMessage(error, errorMessage))\n res.status(error.status).json({ message: extractErrorMessage(error, errorMessage) })\n } else if (error instanceof Error) {\n serverLogger?.error(extractErrorMessage(error, errorMessage))\n res.status(status).json({ message: extractErrorMessage(error, errorMessage) })\n } else {\n res.status(status).json({ message: errorMessage })\n }\n }\n }\n\nexport const cacheControl =\n (args?: CacheControlArgs): RequestWrapper =>\n async (req, res, next) => {\n const { headers = CACHE_DEFAULT_HEADERS, errorHeaders = CACHE_DEFAULT_ERROR_HEADERS } = args || {}\n try {\n res.setHeader('Cache-Control', headers)\n\n await next?.(req, res, next)\n } catch (error) {\n // for requests with cache-control headers\n // need set new headers otherwise error will be cached\n res.setHeader('Cache-Control', errorHeaders)\n\n // throw error up the stack\n throw error\n }\n }\n\nexport const responseTimeMetric =\n (metrics: Histogram<string>, route: string): RequestWrapper =>\n async (req, res, next) => {\n let status = '2xx'\n const endMetric = metrics.startTimer({ route })\n\n try {\n await next?.(req, res, next)\n status = getStatusLabel(res.statusCode)\n } catch (error) {\n status = getStatusLabel(res.statusCode)\n // throw error up the stack\n throw error\n } finally {\n endMetric({ status })\n }\n }\n","export const DEFAULT_API_ERROR_MESSAGE = 'Something went wrong.'\n\nexport const CACHE_DEFAULT_HEADERS = 'public, max-age=180, stale-if-error=1200, stale-while-revalidate=60'\nexport const CACHE_DEFAULT_ERROR_HEADERS = 'no-store, must-revalidate'\n","import { DEFAULT_API_ERROR_MESSAGE } from './constants'\n\nexport const extractErrorMessage = (error: unknown, defaultMessage?: string): string => {\n if (typeof error === 'string') return error\n if (error instanceof Error) return error.message\n return defaultMessage ?? DEFAULT_API_ERROR_MESSAGE\n}\n","import { NextApiResponse, NextApiRequest } from 'next'\nimport { ServerLogger } from '@lidofinance/api-logger'\n\nexport type API<T = void> = (req: NextApiRequest, res: NextApiResponse) => Promise<T> | T\n\nexport type RequestWrapper<T = void> = (\n req: NextApiRequest,\n res: NextApiResponse,\n next?: API<T> | RequestWrapper<T>,\n) => Promise<T> | T\n\nexport type MixedWrapper = <T = void>(api: API<T>) => RequestWrapper<T>\n\nexport type DefaultErrorHandlerArgs = {\n errorMessage?: string\n serverLogger?: ServerLogger\n}\n\nexport type CacheControlArgs = {\n headers?: string\n errorHeaders?: string\n}\n"],"names":[],"version":3,"file":"index.cjs.map"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { NextApiResponse, NextApiRequest } from "next";
2
2
  import { ServerLogger } from "@lidofinance/api-logger";
3
+ import { Histogram } from "prom-client";
3
4
  export type API<T = void> = (req: NextApiRequest, res: NextApiResponse) => Promise<T> | T;
4
5
  export type RequestWrapper<T = void> = (req: NextApiRequest, res: NextApiResponse, next?: API<T> | RequestWrapper<T>) => Promise<T> | T;
5
6
  export type MixedWrapper = <T = void>(api: API<T>) => RequestWrapper<T>;
@@ -17,5 +18,6 @@ export const CACHE_DEFAULT_HEADERS = "public, max-age=180, stale-if-error=1200,
17
18
  export const CACHE_DEFAULT_ERROR_HEADERS = "no-store, must-revalidate";
18
19
  export const defaultErrorHandler: (args?: DefaultErrorHandlerArgs) => RequestWrapper;
19
20
  export const cacheControl: (args?: CacheControlArgs) => RequestWrapper;
21
+ export const responseTimeMetric: (metrics: Histogram<string>, route: string) => RequestWrapper;
20
22
 
21
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;AAGA,gBAAgB,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEzF,2BAA2B,CAAC,GAAG,IAAI,IAAI,CACrC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,eAAe,EACpB,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,KAC9B,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEnB,2BAA2B,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,CAAA;AAEvE,sCAAsC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,CAAA;AAED,+BAA+B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;ACnBD,OAAO,MAAM,uGAGsF,CAAA;ACLnG,OAAO,MAAM,mDAAmD,CAAA;AAEhE,OAAO,MAAM,6FAA6F,CAAA;AAC1G,OAAO,MAAM,yDAAyD,CAAA;AEEtE,OAAO,MAAM,6BACH,uBAAuB,KAAG,cAgBjC,CAAA;AAEH,OAAO,MAAM,sBACH,gBAAgB,KAAG,cAe1B,CAAA","sources":["packages/next/api-wrapper/src/src/types.ts","packages/next/api-wrapper/src/src/wrapRequest.ts","packages/next/api-wrapper/src/src/constants.ts","packages/next/api-wrapper/src/src/utils.ts","packages/next/api-wrapper/src/src/wrappers.ts","packages/next/api-wrapper/src/src/index.ts","packages/next/api-wrapper/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,"export * from './wrapRequest'\nexport * from './wrappers'\nexport * from './constants'\nexport * from './types'\n"],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":";;;AAGA,gBAAgB,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEzF,2BAA2B,CAAC,GAAG,IAAI,IAAI,CACrC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,eAAe,EACpB,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,KAC9B,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEnB,2BAA2B,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,CAAA;AAEvE,sCAAsC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,CAAA;AAED,+BAA+B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;ACnBD,OAAO,MAAM,uGAGsF,CAAA;ACLnG,OAAO,MAAM,mDAAmD,CAAA;AAEhE,OAAO,MAAM,6FAA6F,CAAA;AAC1G,OAAO,MAAM,yDAAyD,CAAA;AEYtE,OAAO,MAAM,6BACH,uBAAuB,KAAG,cAmBjC,CAAA;AAEH,OAAO,MAAM,sBACH,gBAAgB,KAAG,cAe1B,CAAA;AAEH,OAAO,MAAM,8BACD,UAAU,MAAM,CAAC,SAAS,MAAM,KAAG,cAe5C,CAAA","sources":["packages/next/api-wrapper/src/src/types.ts","packages/next/api-wrapper/src/src/wrapRequest.ts","packages/next/api-wrapper/src/src/constants.ts","packages/next/api-wrapper/src/src/utils.ts","packages/next/api-wrapper/src/src/wrappers.ts","packages/next/api-wrapper/src/src/index.ts","packages/next/api-wrapper/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,"export * from './wrapRequest'\nexport * from './wrappers'\nexport * from './constants'\nexport * from './types'\n"],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import {getStatusLabel as $dU25M$getStatusLabel} from "@lidofinance/api-metrics";
2
+
1
3
  function $parcel$export(e, n, v, s) {
2
4
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
3
5
  }
@@ -11,6 +13,8 @@ var $6ca930aaa4992525$exports = {};
11
13
 
12
14
  $parcel$export($6ca930aaa4992525$exports, "defaultErrorHandler", function () { return $6ca930aaa4992525$export$74226d5f34b9550e; });
13
15
  $parcel$export($6ca930aaa4992525$exports, "cacheControl", function () { return $6ca930aaa4992525$export$935bfe081ea97cf4; });
16
+ $parcel$export($6ca930aaa4992525$exports, "responseTimeMetric", function () { return $6ca930aaa4992525$export$156cbc8f54439240; });
17
+
14
18
  var $b2dbcaa42773f73a$exports = {};
15
19
 
16
20
  $parcel$export($b2dbcaa42773f73a$exports, "DEFAULT_API_ERROR_MESSAGE", function () { return $b2dbcaa42773f73a$export$c982278a0ddc4dbe; });
@@ -29,6 +33,10 @@ const $e74a3752b07b80f6$export$8cc545829c7461b0 = (error, defaultMessage)=>{
29
33
  };
30
34
 
31
35
 
36
+ const $6ca930aaa4992525$var$isErrorWithStatus = (error)=>{
37
+ if (typeof error !== "object" || error === null) return false;
38
+ return "status" in error;
39
+ };
32
40
  const $6ca930aaa4992525$export$74226d5f34b9550e = (args)=>{
33
41
  return async (req, res, next)=>{
34
42
  const { errorMessage: errorMessage = (0, $b2dbcaa42773f73a$export$c982278a0ddc4dbe) , serverLogger: serverLogger } = args || {};
@@ -37,7 +45,12 @@ const $6ca930aaa4992525$export$74226d5f34b9550e = (args)=>{
37
45
  } catch (error) {
38
46
  const isInnerError = res.statusCode === 200;
39
47
  const status = isInnerError ? 500 : res.statusCode || 500;
40
- if (error instanceof Error) {
48
+ if ($6ca930aaa4992525$var$isErrorWithStatus(error)) {
49
+ serverLogger === null || serverLogger === void 0 ? void 0 : serverLogger.error((0, $e74a3752b07b80f6$export$8cc545829c7461b0)(error, errorMessage));
50
+ res.status(error.status).json({
51
+ message: (0, $e74a3752b07b80f6$export$8cc545829c7461b0)(error, errorMessage)
52
+ });
53
+ } else if (error instanceof Error) {
41
54
  serverLogger === null || serverLogger === void 0 ? void 0 : serverLogger.error((0, $e74a3752b07b80f6$export$8cc545829c7461b0)(error, errorMessage));
42
55
  res.status(status).json({
43
56
  message: (0, $e74a3752b07b80f6$export$8cc545829c7461b0)(error, errorMessage)
@@ -63,6 +76,26 @@ const $6ca930aaa4992525$export$935bfe081ea97cf4 = (args)=>{
63
76
  }
64
77
  };
65
78
  };
79
+ const $6ca930aaa4992525$export$156cbc8f54439240 = (metrics, route)=>{
80
+ return async (req, res, next)=>{
81
+ let status = "2xx";
82
+ const endMetric = metrics.startTimer({
83
+ route: route
84
+ });
85
+ try {
86
+ await (next === null || next === void 0 ? void 0 : next(req, res, next));
87
+ status = (0, $dU25M$getStatusLabel)(res.statusCode);
88
+ } catch (error) {
89
+ status = (0, $dU25M$getStatusLabel)(res.statusCode);
90
+ // throw error up the stack
91
+ throw error;
92
+ } finally{
93
+ endMetric({
94
+ status: status
95
+ });
96
+ }
97
+ };
98
+ };
66
99
 
67
100
 
68
101
 
@@ -71,5 +104,5 @@ var $f88c1e0fd4c47034$exports = {};
71
104
 
72
105
 
73
106
 
74
- export {$bdaf63d697185839$export$b77e87d9092b0632 as wrapRequest, $6ca930aaa4992525$export$74226d5f34b9550e as defaultErrorHandler, $6ca930aaa4992525$export$935bfe081ea97cf4 as cacheControl, $b2dbcaa42773f73a$export$c982278a0ddc4dbe as DEFAULT_API_ERROR_MESSAGE, $b2dbcaa42773f73a$export$6bec5fc4117189a2 as CACHE_DEFAULT_HEADERS, $b2dbcaa42773f73a$export$a3368692186462a4 as CACHE_DEFAULT_ERROR_HEADERS};
107
+ export {$bdaf63d697185839$export$b77e87d9092b0632 as wrapRequest, $6ca930aaa4992525$export$74226d5f34b9550e as defaultErrorHandler, $6ca930aaa4992525$export$935bfe081ea97cf4 as cacheControl, $6ca930aaa4992525$export$156cbc8f54439240 as responseTimeMetric, $b2dbcaa42773f73a$export$c982278a0ddc4dbe as DEFAULT_API_ERROR_MESSAGE, $b2dbcaa42773f73a$export$6bec5fc4117189a2 as CACHE_DEFAULT_HEADERS, $b2dbcaa42773f73a$export$a3368692186462a4 as CACHE_DEFAULT_ERROR_HEADERS};
75
108
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;ACEO,MAAM,4CACX,CAAW,WACX,CAAC,iBACC,SAAS,MAAM,CAAC,CAAC,KAAK,MAAQ,CAAC,KAAK,MAAQ,IAAI,KAAK,KAAK,IAAM,IAAI,KAAK,OAAO;;ADLpF;;;;;;;;;;AGAO,MAAM,4CAA4B;AAElC,MAAM,4CAAwB;AAC9B,MAAM,4CAA8B;;ADH3C;AEAA;AAEO,MAAM,4CAAsB,CAAC,OAAgB,iBAAoC;IACtF,IAAI,OAAO,UAAU,UAAU,OAAO;IACtC,IAAI,iBAAiB,OAAO,OAAO,MAAM,OAAO;IAChD,OAAO,2BAAA,4BAAA,iBAAkB,CAAA,GAAA,yCAAwB,CAAC;AACpD;;;AFDO,MAAM,4CACX,CAAC;IACD,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,MAAM,gBAAE,eAAe,CAAA,GAAA,yCAAwB,kBAAG,aAAY,EAAE,GAAG,QAAQ,CAAC;QAC5E,IAAI;YACF,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;QACzB,EAAE,OAAO,OAAO;YACd,MAAM,eAAe,IAAI,UAAU,KAAK;YACxC,MAAM,SAAS,eAAe,MAAM,IAAI,UAAU,IAAI,GAAG;YAEzD,IAAI,iBAAiB,OAAO;gBAC1B,yBAAA,0BAAA,KAAA,IAAA,aAAc,KAAK,CAAC,CAAA,GAAA,yCAAkB,EAAE,OAAO;gBAC/C,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;oBAAE,SAAS,CAAA,GAAA,yCAAmB,AAAD,EAAE,OAAO;gBAAc;YAC9E,OACE,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;gBAAE,SAAS;YAAa;QAEpD;IACF;;AAEK,MAAM,4CACX,CAAC;IACD,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,MAAM,WAAE,UAAU,CAAA,GAAA,yCAAoB,kBAAG,eAAe,CAAA,GAAA,yCAA2B,AAAD,IAAG,GAAG,QAAQ,CAAC;QACjG,IAAI;YACF,IAAI,SAAS,CAAC,iBAAiB;YAE/B,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;QACzB,EAAE,OAAO,OAAO;YACd,0CAA0C;YAC1C,sDAAsD;YACtD,IAAI,SAAS,CAAC,iBAAiB;YAE/B,2BAA2B;YAC3B,MAAM,MAAK;QACb;IACF;;;;;;;","sources":["packages/next/api-wrapper/src/index.ts","packages/next/api-wrapper/src/wrapRequest.ts","packages/next/api-wrapper/src/wrappers.ts","packages/next/api-wrapper/src/constants.ts","packages/next/api-wrapper/src/utils.ts","packages/next/api-wrapper/src/types.ts"],"sourcesContent":["export * from './wrapRequest'\nexport * from './wrappers'\nexport * from './constants'\nexport * from './types'\n","import { RequestWrapper, API } from './types'\n\nexport const wrapRequest =\n <T = void>(wrappers: RequestWrapper<T>[]) =>\n (requestHandler: API<T>) =>\n wrappers.reduce((acc, cur) => (req, res) => cur(req, res, () => acc(req, res)), requestHandler)\n","import { DEFAULT_API_ERROR_MESSAGE, CACHE_DEFAULT_ERROR_HEADERS, CACHE_DEFAULT_HEADERS } from './constants'\nimport { extractErrorMessage } from './utils'\nimport { RequestWrapper, DefaultErrorHandlerArgs, CacheControlArgs } from './types'\n\n// must be last in the wrapper stack\nexport const defaultErrorHandler =\n (args?: DefaultErrorHandlerArgs): RequestWrapper =>\n async (req, res, next) => {\n const { errorMessage = DEFAULT_API_ERROR_MESSAGE, serverLogger } = args || {}\n try {\n await next?.(req, res, next)\n } catch (error) {\n const isInnerError = res.statusCode === 200\n const status = isInnerError ? 500 : res.statusCode || 500\n\n if (error instanceof Error) {\n serverLogger?.error(extractErrorMessage(error, errorMessage))\n res.status(status).json({ message: extractErrorMessage(error, errorMessage) })\n } else {\n res.status(status).json({ message: errorMessage })\n }\n }\n }\n\nexport const cacheControl =\n (args?: CacheControlArgs): RequestWrapper =>\n async (req, res, next) => {\n const { headers = CACHE_DEFAULT_HEADERS, errorHeaders = CACHE_DEFAULT_ERROR_HEADERS } = args || {}\n try {\n res.setHeader('Cache-Control', headers)\n\n await next?.(req, res, next)\n } catch (error) {\n // for requests with cache-control headers\n // need set new headers otherwise error will be cached\n res.setHeader('Cache-Control', errorHeaders)\n\n // throw error up the stack\n throw error\n }\n }\n","export const DEFAULT_API_ERROR_MESSAGE = 'Something went wrong.'\n\nexport const CACHE_DEFAULT_HEADERS = 'public, max-age=180, stale-if-error=1200, stale-while-revalidate=60'\nexport const CACHE_DEFAULT_ERROR_HEADERS = 'no-store, must-revalidate'\n","import { DEFAULT_API_ERROR_MESSAGE } from './constants'\n\nexport const extractErrorMessage = (error: unknown, defaultMessage?: string): string => {\n if (typeof error === 'string') return error\n if (error instanceof Error) return error.message\n return defaultMessage ?? DEFAULT_API_ERROR_MESSAGE\n}\n","import { NextApiResponse, NextApiRequest } from 'next'\nimport { ServerLogger } from '@lidofinance/api-logger'\n\nexport type API<T = void> = (req: NextApiRequest, res: NextApiResponse) => Promise<T> | T\n\nexport type RequestWrapper<T = void> = (\n req: NextApiRequest,\n res: NextApiResponse,\n next?: API<T> | RequestWrapper<T>,\n) => Promise<T> | T\n\nexport type MixedWrapper = <T = void>(api: API<T>) => RequestWrapper<T>\n\nexport type DefaultErrorHandlerArgs = {\n errorMessage?: string\n serverLogger?: ServerLogger\n}\n\nexport type CacheControlArgs = {\n headers?: string\n errorHeaders?: string\n}\n"],"names":[],"version":3,"file":"index.mjs.map"}
1
+ {"mappings":";;;;;;;;ACEO,MAAM,4CACX,CAAW,WACX,CAAC,iBACC,SAAS,MAAM,CAAC,CAAC,KAAK,MAAQ,CAAC,KAAK,MAAQ,IAAI,KAAK,KAAK,IAAM,IAAI,KAAK,OAAO;;ADLpF;;;;;;AEAA;;;;;;ACAO,MAAM,4CAA4B;AAElC,MAAM,4CAAwB;AAC9B,MAAM,4CAA8B;;;ACH3C;AAEO,MAAM,4CAAsB,CAAC,OAAgB,iBAAoC;IACtF,IAAI,OAAO,UAAU,UAAU,OAAO;IACtC,IAAI,iBAAiB,OAAO,OAAO,MAAM,OAAO;IAChD,OAAO,2BAAA,4BAAA,iBAAkB,CAAA,GAAA,yCAAwB,CAAC;AACpD;;;AFGA,MAAM,0CAAoB,CAAC,QAA6C;IACtE,IAAI,OAAO,UAAU,YAAY,UAAU,IAAI,EAAE,OAAO,KAAK;IAC7D,OAAO,YAAY;AACrB;AAGO,MAAM,4CACX,CAAC;IACD,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,MAAM,gBAAE,eAAe,CAAA,GAAA,yCAAwB,kBAAG,aAAY,EAAE,GAAG,QAAQ,CAAC;QAC5E,IAAI;YACF,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;QACzB,EAAE,OAAO,OAAO;YACd,MAAM,eAAe,IAAI,UAAU,KAAK;YACxC,MAAM,SAAS,eAAe,MAAM,IAAI,UAAU,IAAI,GAAG;YAEzD,IAAI,wCAAkB,QAAQ;gBAC5B,yBAAA,0BAAA,KAAA,IAAA,aAAc,KAAK,CAAC,CAAA,GAAA,yCAAkB,EAAE,OAAO;gBAC/C,IAAI,MAAM,CAAC,MAAM,MAAM,EAAE,IAAI,CAAC;oBAAE,SAAS,CAAA,GAAA,yCAAmB,AAAD,EAAE,OAAO;gBAAc;YACpF,OAAO,IAAI,iBAAiB,OAAO;gBACjC,yBAAA,0BAAA,KAAA,IAAA,aAAc,KAAK,CAAC,CAAA,GAAA,yCAAkB,EAAE,OAAO;gBAC/C,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;oBAAE,SAAS,CAAA,GAAA,yCAAmB,AAAD,EAAE,OAAO;gBAAc;YAC9E,OACE,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;gBAAE,SAAS;YAAa;QAEpD;IACF;;AAEK,MAAM,4CACX,CAAC;IACD,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,MAAM,WAAE,UAAU,CAAA,GAAA,yCAAoB,kBAAG,eAAe,CAAA,GAAA,yCAA2B,AAAD,IAAG,GAAG,QAAQ,CAAC;QACjG,IAAI;YACF,IAAI,SAAS,CAAC,iBAAiB;YAE/B,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;QACzB,EAAE,OAAO,OAAO;YACd,0CAA0C;YAC1C,sDAAsD;YACtD,IAAI,SAAS,CAAC,iBAAiB;YAE/B,2BAA2B;YAC3B,MAAM,MAAK;QACb;IACF;;AAEK,MAAM,4CACX,CAAC,SAA4B;IAC7B,OAAA,OAAO,KAAK,KAAK,OAAS;QACxB,IAAI,SAAS;QACb,MAAM,YAAY,QAAQ,UAAU,CAAC;mBAAE;QAAM;QAE7C,IAAI;YACF,OAAM,iBAAA,kBAAA,KAAA,IAAA,KAAO,KAAK,KAAK;YACvB,SAAS,CAAA,GAAA,qBAAc,AAAD,EAAE,IAAI,UAAU;QACxC,EAAE,OAAO,OAAO;YACd,SAAS,CAAA,GAAA,qBAAc,AAAD,EAAE,IAAI,UAAU;YACtC,2BAA2B;YAC3B,MAAM,MAAK;QACb,SAAU;YACR,UAAU;wBAAE;YAAO;QACrB;IACF;;;;;;;","sources":["packages/next/api-wrapper/src/index.ts","packages/next/api-wrapper/src/wrapRequest.ts","packages/next/api-wrapper/src/wrappers.ts","packages/next/api-wrapper/src/constants.ts","packages/next/api-wrapper/src/utils.ts","packages/next/api-wrapper/src/types.ts"],"sourcesContent":["export * from './wrapRequest'\nexport * from './wrappers'\nexport * from './constants'\nexport * from './types'\n","import { RequestWrapper, API } from './types'\n\nexport const wrapRequest =\n <T = void>(wrappers: RequestWrapper<T>[]) =>\n (requestHandler: API<T>) =>\n wrappers.reduce((acc, cur) => (req, res) => cur(req, res, () => acc(req, res)), requestHandler)\n","import { Histogram } from 'prom-client'\nimport { getStatusLabel } from '@lidofinance/api-metrics'\n\nimport { DEFAULT_API_ERROR_MESSAGE, CACHE_DEFAULT_ERROR_HEADERS, CACHE_DEFAULT_HEADERS } from './constants'\nimport { extractErrorMessage } from './utils'\nimport { RequestWrapper, DefaultErrorHandlerArgs, CacheControlArgs } from './types'\n\ntype ErrorWithStatus = Error & { status: number }\n\nconst isErrorWithStatus = (error: unknown): error is ErrorWithStatus => {\n if (typeof error !== 'object' || error === null) return false\n return 'status' in error\n}\n\n// must be last in the wrapper stack\nexport const defaultErrorHandler =\n (args?: DefaultErrorHandlerArgs): RequestWrapper =>\n async (req, res, next) => {\n const { errorMessage = DEFAULT_API_ERROR_MESSAGE, serverLogger } = args || {}\n try {\n await next?.(req, res, next)\n } catch (error) {\n const isInnerError = res.statusCode === 200\n const status = isInnerError ? 500 : res.statusCode || 500\n\n if (isErrorWithStatus(error)) {\n serverLogger?.error(extractErrorMessage(error, errorMessage))\n res.status(error.status).json({ message: extractErrorMessage(error, errorMessage) })\n } else if (error instanceof Error) {\n serverLogger?.error(extractErrorMessage(error, errorMessage))\n res.status(status).json({ message: extractErrorMessage(error, errorMessage) })\n } else {\n res.status(status).json({ message: errorMessage })\n }\n }\n }\n\nexport const cacheControl =\n (args?: CacheControlArgs): RequestWrapper =>\n async (req, res, next) => {\n const { headers = CACHE_DEFAULT_HEADERS, errorHeaders = CACHE_DEFAULT_ERROR_HEADERS } = args || {}\n try {\n res.setHeader('Cache-Control', headers)\n\n await next?.(req, res, next)\n } catch (error) {\n // for requests with cache-control headers\n // need set new headers otherwise error will be cached\n res.setHeader('Cache-Control', errorHeaders)\n\n // throw error up the stack\n throw error\n }\n }\n\nexport const responseTimeMetric =\n (metrics: Histogram<string>, route: string): RequestWrapper =>\n async (req, res, next) => {\n let status = '2xx'\n const endMetric = metrics.startTimer({ route })\n\n try {\n await next?.(req, res, next)\n status = getStatusLabel(res.statusCode)\n } catch (error) {\n status = getStatusLabel(res.statusCode)\n // throw error up the stack\n throw error\n } finally {\n endMetric({ status })\n }\n }\n","export const DEFAULT_API_ERROR_MESSAGE = 'Something went wrong.'\n\nexport const CACHE_DEFAULT_HEADERS = 'public, max-age=180, stale-if-error=1200, stale-while-revalidate=60'\nexport const CACHE_DEFAULT_ERROR_HEADERS = 'no-store, must-revalidate'\n","import { DEFAULT_API_ERROR_MESSAGE } from './constants'\n\nexport const extractErrorMessage = (error: unknown, defaultMessage?: string): string => {\n if (typeof error === 'string') return error\n if (error instanceof Error) return error.message\n return defaultMessage ?? DEFAULT_API_ERROR_MESSAGE\n}\n","import { NextApiResponse, NextApiRequest } from 'next'\nimport { ServerLogger } from '@lidofinance/api-logger'\n\nexport type API<T = void> = (req: NextApiRequest, res: NextApiResponse) => Promise<T> | T\n\nexport type RequestWrapper<T = void> = (\n req: NextApiRequest,\n res: NextApiResponse,\n next?: API<T> | RequestWrapper<T>,\n) => Promise<T> | T\n\nexport type MixedWrapper = <T = void>(api: API<T>) => RequestWrapper<T>\n\nexport type DefaultErrorHandlerArgs = {\n errorMessage?: string\n serverLogger?: ServerLogger\n}\n\nexport type CacheControlArgs = {\n headers?: string\n errorHeaders?: string\n}\n"],"names":[],"version":3,"file":"index.mjs.map"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Wrapper for next server api requests",
4
4
  "repository": "git@github.com:lidofinance/warehouse.git",
5
5
  "license": "MIT",
6
- "version": "0.18.0",
6
+ "version": "0.20.0",
7
7
  "files": [
8
8
  "dist"
9
9
  ],
@@ -23,16 +23,19 @@
23
23
  "test": "jest"
24
24
  },
25
25
  "peerDependencies": {
26
- "@lidofinance/api-logger": "~0.18.0",
27
- "next": "^12.2.0"
26
+ "@lidofinance/api-metrics": "~0.20.0",
27
+ "next": "^12.2.0",
28
+ "prom-client": "^14.0.0"
28
29
  },
29
30
  "devDependencies": {
30
- "@lidofinance/api-logger": "~0.18.0",
31
- "@lidofinance/config-prettier": "~0.18.0",
31
+ "@lidofinance/api-logger": "~0.20.0",
32
+ "@lidofinance/api-metrics": "~0.20.0",
33
+ "@lidofinance/config-prettier": "~0.20.0",
32
34
  "@types/jest": "^29.2.4",
33
35
  "@types/node": "^18.11.17",
34
36
  "jest": "^29.3.1",
35
37
  "next": "^12.3.1",
36
- "ts-jest": "^29.0.3"
38
+ "ts-jest": "^29.0.3",
39
+ "prom-client": "^14.0.0"
37
40
  }
38
41
  }