@visulima/api-platform 3.0.13 → 3.0.14

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/chunk-4C666HHU.js +1 -1
  3. package/dist/chunk-4C666HHU.js.map +1 -1
  4. package/dist/chunk-66EUOAFS.mjs +1 -1
  5. package/dist/chunk-66EUOAFS.mjs.map +1 -1
  6. package/dist/chunk-GI7VS3DY.mjs +1 -1
  7. package/dist/chunk-GI7VS3DY.mjs.map +1 -1
  8. package/dist/chunk-HZWWJL43.mjs +1 -1
  9. package/dist/chunk-HZWWJL43.mjs.map +1 -1
  10. package/dist/chunk-MYU5ZKUN.js +1 -1
  11. package/dist/chunk-MYU5ZKUN.js.map +1 -1
  12. package/dist/chunk-T4ABIWHW.mjs +1 -1
  13. package/dist/chunk-T4ABIWHW.mjs.map +1 -1
  14. package/dist/chunk-UPRO35MO.js +1 -1
  15. package/dist/chunk-UPRO35MO.js.map +1 -1
  16. package/dist/{chunk-QHJJMANH.js → chunk-UUYCUP6Z.js} +2 -2
  17. package/dist/chunk-UUYCUP6Z.js.map +1 -0
  18. package/dist/{chunk-JAQUIWDG.mjs → chunk-WSYAFKEJ.mjs} +2 -2
  19. package/dist/chunk-WSYAFKEJ.mjs.map +1 -0
  20. package/dist/chunk-YG667K32.js +1 -1
  21. package/dist/chunk-YG667K32.js.map +1 -1
  22. package/dist/framework/cli/commander/index.js +3 -3
  23. package/dist/framework/cli/commander/index.js.map +1 -1
  24. package/dist/framework/cli/commander/index.mjs +2 -2
  25. package/dist/framework/cli/commander/index.mjs.map +1 -1
  26. package/dist/framework/cli/index.js +3 -3
  27. package/dist/framework/cli/index.js.map +1 -1
  28. package/dist/framework/cli/index.mjs +2 -2
  29. package/dist/framework/cli/index.mjs.map +1 -1
  30. package/dist/framework/next/index-browser.js +1 -1
  31. package/dist/framework/next/index-browser.js.map +1 -1
  32. package/dist/framework/next/index-browser.mjs +1 -1
  33. package/dist/framework/next/index-browser.mjs.map +1 -1
  34. package/dist/framework/next/index-server.js +1 -1
  35. package/dist/framework/next/index-server.js.map +1 -1
  36. package/dist/framework/next/index-server.mjs +1 -1
  37. package/dist/framework/next/index-server.mjs.map +1 -1
  38. package/dist/framework/next/routes/pages/redoc/index.js +1 -1
  39. package/dist/framework/next/routes/pages/redoc/index.js.map +1 -1
  40. package/dist/framework/next/routes/pages/redoc/index.mjs +1 -1
  41. package/dist/framework/next/routes/pages/redoc/index.mjs.map +1 -1
  42. package/dist/framework/next/routes/pages/swagger/index.js +1 -1
  43. package/dist/framework/next/routes/pages/swagger/index.js.map +1 -1
  44. package/dist/framework/next/routes/pages/swagger/index.mjs +1 -1
  45. package/dist/framework/next/routes/pages/swagger/index.mjs.map +1 -1
  46. package/dist/index-browser.js +1 -1
  47. package/dist/index-browser.js.map +1 -1
  48. package/dist/index-browser.mjs +1 -1
  49. package/dist/index-browser.mjs.map +1 -1
  50. package/dist/index-server.js +1 -1
  51. package/dist/index-server.js.map +1 -1
  52. package/dist/index-server.mjs +1 -1
  53. package/dist/index-server.mjs.map +1 -1
  54. package/package.json +15 -15
  55. package/dist/chunk-JAQUIWDG.mjs.map +0 -1
  56. package/dist/chunk-QHJJMANH.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -9,5 +9,5 @@ Object.defineProperty(exports, "getSwaggerStaticProps", {
9
9
  enumerable: true,
10
10
  get: function () { return chunkMYU5ZKUN_js.a; }
11
11
  });
12
- //# sourceMappingURL=out.js.map
12
+ //# sourceMappingURL=index-browser.js.map
13
13
  //# sourceMappingURL=index-browser.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index-browser.js"}
@@ -1,4 +1,4 @@
1
1
  export { a as getSwaggerStaticProps } from '../../chunk-GI7VS3DY.mjs';
2
2
  import '../../chunk-HZWWJL43.mjs';
3
- //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=index-browser.mjs.map
4
4
  //# sourceMappingURL=index-browser.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index-browser.mjs"}
@@ -19,5 +19,5 @@ Object.defineProperty(exports, "getSwaggerStaticProps", {
19
19
  });
20
20
  exports.swaggerApiRoute = l;
21
21
  exports.withOpenApi = x;
22
- //# sourceMappingURL=out.js.map
22
+ //# sourceMappingURL=index-server.js.map
23
23
  //# sourceMappingURL=index-server.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/framework/next/routes/api/swagger.ts","../../../src/framework/next/webpack/with-open-api.ts"],"names":["swaggerApiRoute","options","swagger_handler_default","swagger_default","fs","SwaggerCompilerPlugin","join","withOpenApi","definition","output","sources","verbose","nextConfig","config","source","combinedPath","with_open_api_default"],"mappings":"wHAOA,IAAMA,EAAsH,CAACC,EAAU,CAAC,IACpIC,EAAeD,CAAO,EAGnBE,EAAQH,ECXf,OAAOI,MAAQ,KAGf,OAAS,yBAAAC,MAA6B,2BACtC,OAAS,QAAAC,MAAY,iBAKrB,IAAMC,EACF,CAAC,CACG,WAAAC,EACA,OAAAC,EAAS,uBACT,QAAAC,EACA,QAAAC,CACJ,IAMCC,IACI,CACG,GAAGA,EACH,QAAS,CAACC,EAAuBZ,IAAkC,CAC/D,GAAI,CAACA,EAAQ,SACT,OAAOY,EAQX,GALIJ,EAAO,WAAW,GAAG,IAErBA,EAASA,EAAO,MAAM,CAAC,GAGvB,CAACA,EAAO,SAAS,OAAO,EACxB,MAAM,IAAI,MAAM,qCAAqC,EA6BzD,OAzBAI,EAAS,CACL,GAAGA,EACH,QAAS,CAEL,GAAGA,EAAO,QACV,IAAIR,EACA,GAAGJ,EAAQ,GAAG,IAAIQ,CAAM,GACxBC,EAAQ,IAAKI,GAAW,CACpB,IAAMC,EAAeT,EAAKL,EAAQ,IAAea,EAAO,QAAQ,KAAM,EAAE,CAAC,EAGzE,OAAAV,EAAG,UAAUW,CAAY,EAAE,YAAY,EAEhCA,CACX,CAAC,EACD,CAEI,QAAS,QACT,GAAGP,CACP,EACA,CAAE,QAAAG,CAAQ,CACd,CACJ,CACJ,EAEI,OAAOC,EAAW,SAAY,WACvBA,EAAW,QAAQC,EAAQZ,CAAO,EAGtCY,CACX,CACJ,GAEDG,EAAQT","sourcesContent":["import type { SwaggerHandlerOptions } from \"../../../../swagger/api/swagger-handler\";\nimport swaggerHandler from \"../../../../swagger/api/swagger-handler\";\n\n/**\n * @deprecated Use `import { swaggerHandler } from \"@visulima/api-platform\"` instead.\n */\n\nconst swaggerApiRoute: <M extends string, PrismaClient>(options: Partial<SwaggerHandlerOptions<M, PrismaClient>>) => void = (options = {}) =>\n swaggerHandler(options);\n\n// eslint-disable-next-line deprecation/deprecation\nexport default swaggerApiRoute;\n","import fs from \"node:fs\";\n\nimport type { BaseDefinition } from \"@visulima/jsdoc-open-api\";\nimport { SwaggerCompilerPlugin } from \"@visulima/jsdoc-open-api\";\nimport { join } from \"@visulima/path\";\nimport type { NextJsWebpackConfig, WebpackConfigContext } from \"next/dist/server/config-shared\";\nimport type { NextConfig } from \"next/types\";\nimport type { Configuration } from \"webpack\";\n\nconst withOpenApi =\n ({\n definition,\n output = \"swagger/swagger.json\",\n sources,\n verbose,\n }: {\n definition: Exclude<BaseDefinition, \"openapi\"> & { openapi?: string };\n output: string;\n sources: string[];\n verbose?: boolean;\n }) =>\n (nextConfig: NextConfig): NextConfig =>\n ({\n ...nextConfig,\n webpack: (config: Configuration, options: WebpackConfigContext) => {\n if (!options.isServer) {\n return config;\n }\n\n if (output.startsWith(\"/\")) {\n // eslint-disable-next-line no-param-reassign\n output = output.slice(1);\n }\n\n if (!output.endsWith(\".json\")) {\n throw new Error(\"The output path must end with .json\");\n }\n\n // eslint-disable-next-line no-param-reassign\n config = {\n ...config,\n plugins: [\n // @ts-expect-error: ignore\n ...config.plugins,\n new SwaggerCompilerPlugin(\n `${options.dir}/${output}`,\n sources.map((source) => {\n const combinedPath = join(options.dir as string, source.replace(\"./\", \"\"));\n\n // Check if the path is a directory\n fs.lstatSync(combinedPath).isDirectory();\n\n return combinedPath;\n }),\n {\n // @ts-expect-error: This property should be overwritten\n openapi: \"3.0.0\",\n ...definition,\n },\n { verbose },\n ),\n ],\n };\n\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options) as NextJsWebpackConfig;\n }\n\n return config as NextJsWebpackConfig;\n },\n }) as NextConfig;\n\nexport default withOpenApi;\n"]}
1
+ {"version":3,"sources":["../../../src/framework/next/routes/api/swagger.ts","../../../src/framework/next/webpack/with-open-api.ts"],"names":["swaggerApiRoute","options","swagger_handler_default","swagger_default","withOpenApi","definition","output","sources","verbose","nextConfig","config","SwaggerCompilerPlugin","source","combinedPath","join","fs","with_open_api_default"],"mappings":";;;;;;;;;;;;;AAOA,IAAMA,CAAsH,CAAA,CAACC,CAAU,CAAA,EACnIC,GAAAA,kBAAAA,CAAeD,CAAO,CAAA,CAGnBE,CAAQH,CAAAA,MCFTI,CACF,CAAA,CAAC,CACG,UAAA,CAAAC,CACA,CAAA,MAAA,CAAAC,CAAS,CAAA,sBAAA,CACT,QAAAC,CACA,CAAA,OAAA,CAAAC,CACJ,CAAA,GAMCC,CACI,GAAA,CACG,GAAGA,CAAAA,CACH,QAAS,CAACC,CAAAA,CAAuBT,CAAkC,GAAA,CAC/D,GAAI,CAACA,CAAQ,CAAA,QAAA,CACT,OAAOS,CAQX,CAAA,GALIJ,CAAO,CAAA,UAAA,CAAW,GAAG,CAAA,GAErBA,CAASA,CAAAA,CAAAA,CAAO,MAAM,CAAC,CAAA,CAAA,CAGvB,CAACA,CAAAA,CAAO,QAAS,CAAA,OAAO,CACxB,CAAA,MAAM,IAAI,KAAM,CAAA,qCAAqC,CA6BzD,CAAA,OAzBAI,CAAS,CAAA,CACL,GAAGA,CAAAA,CACH,OAAS,CAAA,CAEL,GAAGA,CAAAA,CAAO,OACV,CAAA,IAAIC,kCACA,CAAA,CAAA,EAAGV,EAAQ,GAAG,CAAA,CAAA,EAAIK,CAAM,CAAA,CAAA,CACxBC,CAAQ,CAAA,GAAA,CAAKK,CAAW,EAAA,CACpB,IAAMC,CAAeC,CAAAA,SAAAA,CAAKb,CAAQ,CAAA,GAAA,CAAeW,CAAO,CAAA,OAAA,CAAQ,IAAM,CAAA,EAAE,CAAC,CAGzE,CAAA,OAAAG,kBAAG,CAAA,SAAA,CAAUF,CAAY,CAAA,CAAE,WAAY,EAAA,CAEhCA,CACX,CAAC,CAAA,CACD,CAEI,OAAA,CAAS,OACT,CAAA,GAAGR,CACP,CAAA,CACA,CAAE,OAAAG,CAAAA,CAAQ,CACd,CACJ,CACJ,CAAA,CAEI,OAAOC,CAAAA,CAAW,SAAY,UACvBA,CAAAA,CAAAA,CAAW,OAAQC,CAAAA,CAAAA,CAAQT,CAAO,CAAA,CAGtCS,CACX,CACJ,GAEDM,CAAQZ,CAAAA","file":"index-server.js","sourcesContent":["import type { SwaggerHandlerOptions } from \"../../../../swagger/api/swagger-handler\";\nimport swaggerHandler from \"../../../../swagger/api/swagger-handler\";\n\n/**\n * @deprecated Use `import { swaggerHandler } from \"@visulima/api-platform\"` instead.\n */\n\nconst swaggerApiRoute: <M extends string, PrismaClient>(options: Partial<SwaggerHandlerOptions<M, PrismaClient>>) => void = (options = {}) =>\n swaggerHandler(options);\n\n// eslint-disable-next-line deprecation/deprecation\nexport default swaggerApiRoute;\n","import fs from \"node:fs\";\n\nimport type { BaseDefinition } from \"@visulima/jsdoc-open-api\";\nimport { SwaggerCompilerPlugin } from \"@visulima/jsdoc-open-api\";\nimport { join } from \"@visulima/path\";\nimport type { NextJsWebpackConfig, WebpackConfigContext } from \"next/dist/server/config-shared\";\nimport type { NextConfig } from \"next/types\";\nimport type { Configuration } from \"webpack\";\n\nconst withOpenApi =\n ({\n definition,\n output = \"swagger/swagger.json\",\n sources,\n verbose,\n }: {\n definition: Exclude<BaseDefinition, \"openapi\"> & { openapi?: string };\n output: string;\n sources: string[];\n verbose?: boolean;\n }) =>\n (nextConfig: NextConfig): NextConfig =>\n ({\n ...nextConfig,\n webpack: (config: Configuration, options: WebpackConfigContext) => {\n if (!options.isServer) {\n return config;\n }\n\n if (output.startsWith(\"/\")) {\n // eslint-disable-next-line no-param-reassign\n output = output.slice(1);\n }\n\n if (!output.endsWith(\".json\")) {\n throw new Error(\"The output path must end with .json\");\n }\n\n // eslint-disable-next-line no-param-reassign\n config = {\n ...config,\n plugins: [\n // @ts-expect-error: ignore\n ...config.plugins,\n new SwaggerCompilerPlugin(\n `${options.dir}/${output}`,\n sources.map((source) => {\n const combinedPath = join(options.dir as string, source.replace(\"./\", \"\"));\n\n // Check if the path is a directory\n fs.lstatSync(combinedPath).isDirectory();\n\n return combinedPath;\n }),\n {\n // @ts-expect-error: This property should be overwritten\n openapi: \"3.0.0\",\n ...definition,\n },\n { verbose },\n ),\n ],\n };\n\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options) as NextJsWebpackConfig;\n }\n\n return config as NextJsWebpackConfig;\n },\n }) as NextConfig;\n\nexport default withOpenApi;\n"]}
@@ -8,5 +8,5 @@ import { join } from '@visulima/path';
8
8
  var l=(i={})=>c(i),d=l;var x=({definition:i,output:r="swagger/swagger.json",sources:g,verbose:f})=>o=>({...o,webpack:(e,t)=>{if(!t.isServer)return e;if(r.startsWith("/")&&(r=r.slice(1)),!r.endsWith(".json"))throw new Error("The output path must end with .json");return e={...e,plugins:[...e.plugins,new SwaggerCompilerPlugin(`${t.dir}/${r}`,g.map(m=>{let n=join(t.dir,m.replace("./",""));return w.lstatSync(n).isDirectory(),n}),{openapi:"3.0.0",...i},{verbose:f})]},typeof o.webpack=="function"?o.webpack(e,t):e}}),C=x;
9
9
 
10
10
  export { d as swaggerApiRoute, C as withOpenApi };
11
- //# sourceMappingURL=out.js.map
11
+ //# sourceMappingURL=index-server.mjs.map
12
12
  //# sourceMappingURL=index-server.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/framework/next/routes/api/swagger.ts","../../../src/framework/next/webpack/with-open-api.ts"],"names":["swaggerApiRoute","options","swagger_handler_default","swagger_default","fs","SwaggerCompilerPlugin","join","withOpenApi","definition","output","sources","verbose","nextConfig","config","source","combinedPath","with_open_api_default"],"mappings":"2HAOA,IAAMA,EAAsH,CAACC,EAAU,CAAC,IACpIC,EAAeD,CAAO,EAGnBE,EAAQH,ECXf,OAAOI,MAAQ,UAGf,OAAS,yBAAAC,MAA6B,2BACtC,OAAS,QAAAC,MAAY,iBAKrB,IAAMC,EACF,CAAC,CACG,WAAAC,EACA,OAAAC,EAAS,uBACT,QAAAC,EACA,QAAAC,CACJ,IAMCC,IACI,CACG,GAAGA,EACH,QAAS,CAACC,EAAuBZ,IAAkC,CAC/D,GAAI,CAACA,EAAQ,SACT,OAAOY,EAQX,GALIJ,EAAO,WAAW,GAAG,IAErBA,EAASA,EAAO,MAAM,CAAC,GAGvB,CAACA,EAAO,SAAS,OAAO,EACxB,MAAM,IAAI,MAAM,qCAAqC,EA6BzD,OAzBAI,EAAS,CACL,GAAGA,EACH,QAAS,CAEL,GAAGA,EAAO,QACV,IAAIR,EACA,GAAGJ,EAAQ,GAAG,IAAIQ,CAAM,GACxBC,EAAQ,IAAKI,GAAW,CACpB,IAAMC,EAAeT,EAAKL,EAAQ,IAAea,EAAO,QAAQ,KAAM,EAAE,CAAC,EAGzE,OAAAV,EAAG,UAAUW,CAAY,EAAE,YAAY,EAEhCA,CACX,CAAC,EACD,CAEI,QAAS,QACT,GAAGP,CACP,EACA,CAAE,QAAAG,CAAQ,CACd,CACJ,CACJ,EAEI,OAAOC,EAAW,SAAY,WACvBA,EAAW,QAAQC,EAAQZ,CAAO,EAGtCY,CACX,CACJ,GAEDG,EAAQT","sourcesContent":["import type { SwaggerHandlerOptions } from \"../../../../swagger/api/swagger-handler\";\nimport swaggerHandler from \"../../../../swagger/api/swagger-handler\";\n\n/**\n * @deprecated Use `import { swaggerHandler } from \"@visulima/api-platform\"` instead.\n */\n\nconst swaggerApiRoute: <M extends string, PrismaClient>(options: Partial<SwaggerHandlerOptions<M, PrismaClient>>) => void = (options = {}) =>\n swaggerHandler(options);\n\n// eslint-disable-next-line deprecation/deprecation\nexport default swaggerApiRoute;\n","import fs from \"node:fs\";\n\nimport type { BaseDefinition } from \"@visulima/jsdoc-open-api\";\nimport { SwaggerCompilerPlugin } from \"@visulima/jsdoc-open-api\";\nimport { join } from \"@visulima/path\";\nimport type { NextJsWebpackConfig, WebpackConfigContext } from \"next/dist/server/config-shared\";\nimport type { NextConfig } from \"next/types\";\nimport type { Configuration } from \"webpack\";\n\nconst withOpenApi =\n ({\n definition,\n output = \"swagger/swagger.json\",\n sources,\n verbose,\n }: {\n definition: Exclude<BaseDefinition, \"openapi\"> & { openapi?: string };\n output: string;\n sources: string[];\n verbose?: boolean;\n }) =>\n (nextConfig: NextConfig): NextConfig =>\n ({\n ...nextConfig,\n webpack: (config: Configuration, options: WebpackConfigContext) => {\n if (!options.isServer) {\n return config;\n }\n\n if (output.startsWith(\"/\")) {\n // eslint-disable-next-line no-param-reassign\n output = output.slice(1);\n }\n\n if (!output.endsWith(\".json\")) {\n throw new Error(\"The output path must end with .json\");\n }\n\n // eslint-disable-next-line no-param-reassign\n config = {\n ...config,\n plugins: [\n // @ts-expect-error: ignore\n ...config.plugins,\n new SwaggerCompilerPlugin(\n `${options.dir}/${output}`,\n sources.map((source) => {\n const combinedPath = join(options.dir as string, source.replace(\"./\", \"\"));\n\n // Check if the path is a directory\n fs.lstatSync(combinedPath).isDirectory();\n\n return combinedPath;\n }),\n {\n // @ts-expect-error: This property should be overwritten\n openapi: \"3.0.0\",\n ...definition,\n },\n { verbose },\n ),\n ],\n };\n\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options) as NextJsWebpackConfig;\n }\n\n return config as NextJsWebpackConfig;\n },\n }) as NextConfig;\n\nexport default withOpenApi;\n"]}
1
+ {"version":3,"sources":["../../../src/framework/next/routes/api/swagger.ts","../../../src/framework/next/webpack/with-open-api.ts"],"names":["swaggerApiRoute","options","swagger_handler_default","swagger_default","withOpenApi","definition","output","sources","verbose","nextConfig","config","SwaggerCompilerPlugin","source","combinedPath","join","fs","with_open_api_default"],"mappings":";;;;;;;AAOA,IAAMA,CAAsH,CAAA,CAACC,CAAU,CAAA,EACnIC,GAAAA,CAAAA,CAAeD,CAAO,CAAA,CAGnBE,CAAQH,CAAAA,MCFTI,CACF,CAAA,CAAC,CACG,UAAA,CAAAC,CACA,CAAA,MAAA,CAAAC,CAAS,CAAA,sBAAA,CACT,QAAAC,CACA,CAAA,OAAA,CAAAC,CACJ,CAAA,GAMCC,CACI,GAAA,CACG,GAAGA,CAAAA,CACH,QAAS,CAACC,CAAAA,CAAuBT,CAAkC,GAAA,CAC/D,GAAI,CAACA,CAAQ,CAAA,QAAA,CACT,OAAOS,CAQX,CAAA,GALIJ,CAAO,CAAA,UAAA,CAAW,GAAG,CAAA,GAErBA,CAASA,CAAAA,CAAAA,CAAO,MAAM,CAAC,CAAA,CAAA,CAGvB,CAACA,CAAAA,CAAO,QAAS,CAAA,OAAO,CACxB,CAAA,MAAM,IAAI,KAAM,CAAA,qCAAqC,CA6BzD,CAAA,OAzBAI,CAAS,CAAA,CACL,GAAGA,CAAAA,CACH,OAAS,CAAA,CAEL,GAAGA,CAAAA,CAAO,OACV,CAAA,IAAIC,qBACA,CAAA,CAAA,EAAGV,EAAQ,GAAG,CAAA,CAAA,EAAIK,CAAM,CAAA,CAAA,CACxBC,CAAQ,CAAA,GAAA,CAAKK,CAAW,EAAA,CACpB,IAAMC,CAAeC,CAAAA,IAAAA,CAAKb,CAAQ,CAAA,GAAA,CAAeW,CAAO,CAAA,OAAA,CAAQ,IAAM,CAAA,EAAE,CAAC,CAGzE,CAAA,OAAAG,CAAG,CAAA,SAAA,CAAUF,CAAY,CAAA,CAAE,WAAY,EAAA,CAEhCA,CACX,CAAC,CAAA,CACD,CAEI,OAAA,CAAS,OACT,CAAA,GAAGR,CACP,CAAA,CACA,CAAE,OAAAG,CAAAA,CAAQ,CACd,CACJ,CACJ,CAAA,CAEI,OAAOC,CAAAA,CAAW,SAAY,UACvBA,CAAAA,CAAAA,CAAW,OAAQC,CAAAA,CAAAA,CAAQT,CAAO,CAAA,CAGtCS,CACX,CACJ,GAEDM,CAAQZ,CAAAA","file":"index-server.mjs","sourcesContent":["import type { SwaggerHandlerOptions } from \"../../../../swagger/api/swagger-handler\";\nimport swaggerHandler from \"../../../../swagger/api/swagger-handler\";\n\n/**\n * @deprecated Use `import { swaggerHandler } from \"@visulima/api-platform\"` instead.\n */\n\nconst swaggerApiRoute: <M extends string, PrismaClient>(options: Partial<SwaggerHandlerOptions<M, PrismaClient>>) => void = (options = {}) =>\n swaggerHandler(options);\n\n// eslint-disable-next-line deprecation/deprecation\nexport default swaggerApiRoute;\n","import fs from \"node:fs\";\n\nimport type { BaseDefinition } from \"@visulima/jsdoc-open-api\";\nimport { SwaggerCompilerPlugin } from \"@visulima/jsdoc-open-api\";\nimport { join } from \"@visulima/path\";\nimport type { NextJsWebpackConfig, WebpackConfigContext } from \"next/dist/server/config-shared\";\nimport type { NextConfig } from \"next/types\";\nimport type { Configuration } from \"webpack\";\n\nconst withOpenApi =\n ({\n definition,\n output = \"swagger/swagger.json\",\n sources,\n verbose,\n }: {\n definition: Exclude<BaseDefinition, \"openapi\"> & { openapi?: string };\n output: string;\n sources: string[];\n verbose?: boolean;\n }) =>\n (nextConfig: NextConfig): NextConfig =>\n ({\n ...nextConfig,\n webpack: (config: Configuration, options: WebpackConfigContext) => {\n if (!options.isServer) {\n return config;\n }\n\n if (output.startsWith(\"/\")) {\n // eslint-disable-next-line no-param-reassign\n output = output.slice(1);\n }\n\n if (!output.endsWith(\".json\")) {\n throw new Error(\"The output path must end with .json\");\n }\n\n // eslint-disable-next-line no-param-reassign\n config = {\n ...config,\n plugins: [\n // @ts-expect-error: ignore\n ...config.plugins,\n new SwaggerCompilerPlugin(\n `${options.dir}/${output}`,\n sources.map((source) => {\n const combinedPath = join(options.dir as string, source.replace(\"./\", \"\"));\n\n // Check if the path is a directory\n fs.lstatSync(combinedPath).isDirectory();\n\n return combinedPath;\n }),\n {\n // @ts-expect-error: This property should be overwritten\n openapi: \"3.0.0\",\n ...definition,\n },\n { verbose },\n ),\n ],\n };\n\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options) as NextJsWebpackConfig;\n }\n\n return config as NextJsWebpackConfig;\n },\n }) as NextConfig;\n\nexport default withOpenApi;\n"]}
@@ -16,7 +16,7 @@ body {
16
16
  `})]}),jsxRuntime.jsx(redoc.RedocStandalone,{...p,spec:r})]}),y=i;
17
17
 
18
18
  module.exports = y;
19
- //# sourceMappingURL=out.js.map
19
+ //# sourceMappingURL=index.js.map
20
20
 
21
21
  module.exports = module.exports;
22
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/framework/next/routes/pages/redoc/index.tsx"],"names":["Head","RedocStandalone","Fragment","jsx","jsxs","RedocApiDocument","name","swagger","swaggerData","redoc_default"],"mappings":"yCAAA,OAAOA,MAAU,YAEjB,OAAS,mBAAAC,MAAuB,QAexB,mBAAAC,EAEQ,OAAAC,EADJ,QAAAC,MADJ,oBAXR,IAAMC,EASF,CAACC,EAAMC,EAAU,CAAC,IAClB,CAAC,CAAE,YAAAC,CAAY,IACXJ,EAAAF,EAAA,CACI,UAAAE,EAACJ,EAAA,CACG,UAAAG,EAAC,SAAO,SAAAG,EAAK,EACbH,EAAC,SACI;AAAA;AAAA;AAAA;AAAA,EAKL,GACJ,EAEAA,EAACF,EAAA,CAAiB,GAAGM,EAAS,KAAMC,EAAa,GACrD,EAGDC,EAAQJ","sourcesContent":["import Head from \"next/head\";\nimport type { InferGetStaticPropsType, NextPage } from \"next/types\";\nimport { RedocStandalone } from \"redoc\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst RedocApiDocument: (\n name: string,\n swagger?: Exclude<\n {\n specUrl?: string;\n },\n \"spec\"\n >,\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <RedocStandalone {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default RedocApiDocument;\n"]}
1
+ {"version":3,"sources":["../../../../../../src/framework/next/routes/pages/redoc/index.tsx"],"names":["RedocApiDocument","name","swagger","swaggerData","jsxs","Fragment","Head","jsx","RedocStandalone","redoc_default"],"mappings":";;;;;;;;;;;IAMMA,CASF,CAAA,CAACC,EAAMC,CAAU,CAAA,EACjB,GAAA,CAAC,CAAE,WAAAC,CAAAA,CAAY,IACXC,eAAAC,CAAAA,mBAAAA,CAAA,CACI,QAAAD,CAAAA,CAAAA,eAAAA,CAACE,kBAAA,CAAA,CACG,UAAAC,cAAC,CAAA,OAAA,CAAA,CAAO,SAAAN,CAAK,CAAA,CAAA,CACbM,eAAC,OACI,CAAA,CAAA,QAAA,CAAA,CAAA;AAAA;AAAA;AAAA;AAAA,CAKL,CAAA,CAAA,CAAA,CACJ,CAEAA,CAAAA,cAAAA,CAACC,qBAAA,CAAA,CAAiB,GAAGN,CAAAA,CAAS,IAAMC,CAAAA,CAAAA,CAAa,CACrD,CAAA,CAAA,CAAA,CAGDM,CAAQT,CAAAA","file":"index.js","sourcesContent":["import Head from \"next/head\";\nimport type { InferGetStaticPropsType, NextPage } from \"next/types\";\nimport { RedocStandalone } from \"redoc\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst RedocApiDocument: (\n name: string,\n swagger?: Exclude<\n {\n specUrl?: string;\n },\n \"spec\"\n >,\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <RedocStandalone {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default RedocApiDocument;\n"]}
@@ -10,5 +10,5 @@ body {
10
10
  `})]}),jsx(RedocStandalone,{...p,spec:r})]}),m=i;
11
11
 
12
12
  export { m as default };
13
- //# sourceMappingURL=out.js.map
13
+ //# sourceMappingURL=index.mjs.map
14
14
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/framework/next/routes/pages/redoc/index.tsx"],"names":["Head","RedocStandalone","Fragment","jsx","jsxs","RedocApiDocument","name","swagger","swaggerData","redoc_default"],"mappings":"0CAAA,OAAOA,MAAU,YAEjB,OAAS,mBAAAC,MAAuB,QAexB,mBAAAC,EAEQ,OAAAC,EADJ,QAAAC,MADJ,oBAXR,IAAMC,EASF,CAACC,EAAMC,EAAU,CAAC,IAClB,CAAC,CAAE,YAAAC,CAAY,IACXJ,EAAAF,EAAA,CACI,UAAAE,EAACJ,EAAA,CACG,UAAAG,EAAC,SAAO,SAAAG,EAAK,EACbH,EAAC,SACI;AAAA;AAAA;AAAA;AAAA,EAKL,GACJ,EAEAA,EAACF,EAAA,CAAiB,GAAGM,EAAS,KAAMC,EAAa,GACrD,EAGDC,EAAQJ","sourcesContent":["import Head from \"next/head\";\nimport type { InferGetStaticPropsType, NextPage } from \"next/types\";\nimport { RedocStandalone } from \"redoc\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst RedocApiDocument: (\n name: string,\n swagger?: Exclude<\n {\n specUrl?: string;\n },\n \"spec\"\n >,\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <RedocStandalone {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default RedocApiDocument;\n"]}
1
+ {"version":3,"sources":["../../../../../../src/framework/next/routes/pages/redoc/index.tsx"],"names":["RedocApiDocument","name","swagger","swaggerData","jsxs","Fragment","Head","jsx","RedocStandalone","redoc_default"],"mappings":";;;;;IAMMA,CASF,CAAA,CAACC,EAAMC,CAAU,CAAA,EACjB,GAAA,CAAC,CAAE,WAAAC,CAAAA,CAAY,IACXC,IAAAC,CAAAA,QAAAA,CAAA,CACI,QAAAD,CAAAA,CAAAA,IAAAA,CAACE,CAAA,CAAA,CACG,UAAAC,GAAC,CAAA,OAAA,CAAA,CAAO,SAAAN,CAAK,CAAA,CAAA,CACbM,IAAC,OACI,CAAA,CAAA,QAAA,CAAA,CAAA;AAAA;AAAA;AAAA;AAAA,CAKL,CAAA,CAAA,CAAA,CACJ,CAEAA,CAAAA,GAAAA,CAACC,eAAA,CAAA,CAAiB,GAAGN,CAAAA,CAAS,IAAMC,CAAAA,CAAAA,CAAa,CACrD,CAAA,CAAA,CAAA,CAGDM,CAAQT,CAAAA","file":"index.mjs","sourcesContent":["import Head from \"next/head\";\nimport type { InferGetStaticPropsType, NextPage } from \"next/types\";\nimport { RedocStandalone } from \"redoc\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst RedocApiDocument: (\n name: string,\n swagger?: Exclude<\n {\n specUrl?: string;\n },\n \"spec\"\n >,\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <RedocStandalone {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default RedocApiDocument;\n"]}
@@ -17,7 +17,7 @@ body {
17
17
  `})]}),jsxRuntime.jsx(g,{...a,spec:p})]}),n=i;
18
18
 
19
19
  module.exports = n;
20
- //# sourceMappingURL=out.js.map
20
+ //# sourceMappingURL=index.js.map
21
21
 
22
22
  module.exports = module.exports;
23
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/framework/next/routes/pages/swagger/index.tsx"],"names":["dynamic","Head","Fragment","jsx","jsxs","SwaggerUi","SwaggerApiDocument","name","swagger","swaggerData","swagger_default"],"mappings":"yCAAA,OAAOA,MAAa,eACpB,OAAOC,MAAU,YAWT,mBAAAC,EAEQ,OAAAC,EADJ,QAAAC,MADJ,oBALR,IAAMC,EAAYL,EAAQ,SAAY,KAAM,QAAO,kBAAkB,EAAG,CAAE,IAAK,EAAM,CAAC,EAEhFM,EACF,CAACC,EAAMC,EAAU,CAAC,IAClB,CAAC,CAAE,YAAAC,CAAY,IACXL,EAAAF,EAAA,CACI,UAAAE,EAACH,EAAA,CACG,UAAAE,EAAC,SAAO,SAAAI,EAAK,EACbJ,EAAC,SACI;AAAA;AAAA;AAAA;AAAA,EAKL,GACJ,EAGAA,EAACE,EAAA,CAAW,GAAGG,EAAS,KAAMC,EAAa,GAC/C,EAGDC,EAAQJ","sourcesContent":["import dynamic from \"next/dynamic\";\nimport Head from \"next/head\";\nimport type { InferGetStaticPropsType, NextPage } from \"next/types\";\nimport type { SwaggerUIProps } from \"swagger-ui-react\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst SwaggerUi = dynamic(async () => await import(\"swagger-ui-react\"), { ssr: false });\n\nconst SwaggerApiDocument: (name: string, swagger?: Exclude<SwaggerUIProps, \"spec\">) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <SwaggerUi {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default SwaggerApiDocument;\n"]}
1
+ {"version":3,"sources":["../../../../../../src/framework/next/routes/pages/swagger/index.tsx"],"names":["SwaggerUi","dynamic","SwaggerApiDocument","name","swagger","swaggerData","jsxs","Fragment","Head","jsx","swagger_default"],"mappings":";;;;;;;;;;;;AAOMA,IAAAA,CAAAA,CAAYC,kBAAQ,CAAA,SAAY,MAAM,OAAO,kBAAkB,CAAG,CAAA,CAAE,GAAK,CAAA,CAAA,CAAM,CAAC,CAAA,CAEhFC,EACF,CAACC,CAAAA,CAAMC,EAAU,EAAC,GAClB,CAAC,CAAE,WAAA,CAAAC,CAAY,CAAA,GACXC,eAAAC,CAAAA,mBAAAA,CAAA,CACI,QAAAD,CAAAA,CAAAA,eAAAA,CAACE,kBAAA,CAAA,CACG,QAAAC,CAAAA,CAAAA,cAAAA,CAAC,SAAO,QAAAN,CAAAA,CAAAA,CAAK,CACbM,CAAAA,cAAAA,CAAC,OACI,CAAA,CAAA,QAAA,CAAA,CAAA;AAAA;AAAA;AAAA;AAAA,CAKL,CAAA,CAAA,CAAA,CACJ,CAGAA,CAAAA,cAAAA,CAACT,CAAA,CAAA,CAAW,GAAGI,CAAAA,CAAS,IAAMC,CAAAA,CAAAA,CAAa,CAC/C,CAAA,CAAA,CAAA,CAGDK,CAAQR,CAAAA","file":"index.js","sourcesContent":["import dynamic from \"next/dynamic\";\nimport Head from \"next/head\";\nimport type { InferGetStaticPropsType, NextPage } from \"next/types\";\nimport type { SwaggerUIProps } from \"swagger-ui-react\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst SwaggerUi = dynamic(async () => await import(\"swagger-ui-react\"), { ssr: false });\n\nconst SwaggerApiDocument: (name: string, swagger?: Exclude<SwaggerUIProps, \"spec\">) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <SwaggerUi {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default SwaggerApiDocument;\n"]}
@@ -10,5 +10,5 @@ body {
10
10
  `})]}),jsx(g,{...a,spec:p})]}),P=i;
11
11
 
12
12
  export { P as default };
13
- //# sourceMappingURL=out.js.map
13
+ //# sourceMappingURL=index.mjs.map
14
14
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/framework/next/routes/pages/swagger/index.tsx"],"names":["dynamic","Head","Fragment","jsx","jsxs","SwaggerUi","SwaggerApiDocument","name","swagger","swaggerData","swagger_default"],"mappings":"0CAAA,OAAOA,MAAa,eACpB,OAAOC,MAAU,YAWT,mBAAAC,EAEQ,OAAAC,EADJ,QAAAC,MADJ,oBALR,IAAMC,EAAYL,EAAQ,SAAY,KAAM,QAAO,kBAAkB,EAAG,CAAE,IAAK,EAAM,CAAC,EAEhFM,EACF,CAACC,EAAMC,EAAU,CAAC,IAClB,CAAC,CAAE,YAAAC,CAAY,IACXL,EAAAF,EAAA,CACI,UAAAE,EAACH,EAAA,CACG,UAAAE,EAAC,SAAO,SAAAI,EAAK,EACbJ,EAAC,SACI;AAAA;AAAA;AAAA;AAAA,EAKL,GACJ,EAGAA,EAACE,EAAA,CAAW,GAAGG,EAAS,KAAMC,EAAa,GAC/C,EAGDC,EAAQJ","sourcesContent":["import dynamic from \"next/dynamic\";\nimport Head from \"next/head\";\nimport type { InferGetStaticPropsType, NextPage } from \"next/types\";\nimport type { SwaggerUIProps } from \"swagger-ui-react\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst SwaggerUi = dynamic(async () => await import(\"swagger-ui-react\"), { ssr: false });\n\nconst SwaggerApiDocument: (name: string, swagger?: Exclude<SwaggerUIProps, \"spec\">) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <SwaggerUi {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default SwaggerApiDocument;\n"]}
1
+ {"version":3,"sources":["../../../../../../src/framework/next/routes/pages/swagger/index.tsx"],"names":["SwaggerUi","dynamic","SwaggerApiDocument","name","swagger","swaggerData","jsxs","Fragment","Head","jsx","swagger_default"],"mappings":";;;;;AAOMA,IAAAA,CAAAA,CAAYC,CAAQ,CAAA,SAAY,MAAM,OAAO,kBAAkB,CAAG,CAAA,CAAE,GAAK,CAAA,CAAA,CAAM,CAAC,CAAA,CAEhFC,EACF,CAACC,CAAAA,CAAMC,EAAU,EAAC,GAClB,CAAC,CAAE,WAAA,CAAAC,CAAY,CAAA,GACXC,IAAAC,CAAAA,QAAAA,CAAA,CACI,QAAAD,CAAAA,CAAAA,IAAAA,CAACE,CAAA,CAAA,CACG,QAAAC,CAAAA,CAAAA,GAAAA,CAAC,SAAO,QAAAN,CAAAA,CAAAA,CAAK,CACbM,CAAAA,GAAAA,CAAC,OACI,CAAA,CAAA,QAAA,CAAA,CAAA;AAAA;AAAA;AAAA;AAAA,CAKL,CAAA,CAAA,CAAA,CACJ,CAGAA,CAAAA,GAAAA,CAACT,CAAA,CAAA,CAAW,GAAGI,CAAAA,CAAS,IAAMC,CAAAA,CAAAA,CAAa,CAC/C,CAAA,CAAA,CAAA,CAGDK,CAAQR,CAAAA","file":"index.mjs","sourcesContent":["import dynamic from \"next/dynamic\";\nimport Head from \"next/head\";\nimport type { InferGetStaticPropsType, NextPage } from \"next/types\";\nimport type { SwaggerUIProps } from \"swagger-ui-react\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst SwaggerUi = dynamic(async () => await import(\"swagger-ui-react\"), { ssr: false });\n\nconst SwaggerApiDocument: (name: string, swagger?: Exclude<SwaggerUIProps, \"spec\">) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <SwaggerUi {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default SwaggerApiDocument;\n"]}
@@ -9,5 +9,5 @@ Object.defineProperty(exports, "zod", {
9
9
  enumerable: true,
10
10
  get: function () { return chunkUPRO35MO_js.c; }
11
11
  });
12
- //# sourceMappingURL=out.js.map
12
+ //# sourceMappingURL=index-browser.js.map
13
13
  //# sourceMappingURL=index-browser.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index-browser.js"}
@@ -1,4 +1,4 @@
1
1
  export { c as zod } from './chunk-66EUOAFS.mjs';
2
2
  import './chunk-HZWWJL43.mjs';
3
- //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=index-browser.mjs.map
4
4
  //# sourceMappingURL=index-browser.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index-browser.mjs"}
@@ -243,5 +243,5 @@ exports.rateLimiterMiddleware = me;
243
243
  exports.serialize = m;
244
244
  exports.serializersMiddleware = w;
245
245
  exports.xmlTransformer = y;
246
- //# sourceMappingURL=out.js.map
246
+ //# sourceMappingURL=index-server.js.map
247
247
  //# sourceMappingURL=index-server.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connect/create-node-router.ts","../src/connect/handler.ts","../src/error-handler/jsonapi-error-handler.ts","../src/error-handler/utils.ts","../src/error-handler/problem-error-handler.ts","../src/connect/middleware/http-header-normalizer.ts","../src/connect/middleware/serializers-middleware.ts","../src/serializers/serialize.ts","../src/serializers/has-json-structure.ts","../src/serializers/transformer/xml.ts","../src/connect/middleware/cors-middleware.ts","../src/connect/middleware/rate-limiter-middleware.ts","../src/index-server.ts"],"names":["NodeRouter","createHttpError","HttpError","getReasonPhrase","tsJapi","StatusCodes","setErrorHeaders","response","error","headers","header","sendJson","jsonBody","addStatusCodeToResponse","defaultTitle","jsonapiErrorHandler","_request","serializer","message","statusCode","title","jsonapi_error_handler_default","defaultType","problemErrorHandler","stack","expose","type","problem_error_handler_default","onError","errorHandlers","showTrace","request","apiFormat","errorHandler","handler","regex","onNoMatch","routes","uniqueMethods","route","exceptions","normalizeHeaderKey","key","canonical","lowerCaseKey","text","defaults","httpHeaderNormalizerMiddleware","options_","options","_","next","rawHeaders","normalizedKey","http_header_normalizer_default","debug","accepts","hasJsonStructure","data","result","has_json_structure_default","toXML","xmlTransformer","xml_default","contentTypeKey","serialize","serializers","types","serializedData","breakTypes","yaml_default","toHeaderCase","serialize_default","log","serializersMiddleware","defaultContentType","oldSend","oldEnd","arguments_","serializers_middleware_default","createNodeRouter","create_node_router_default","expressWrapper","cors","corsMiddleware","cors_middleware_default","getIP","rateLimiterMiddleware","rateLimiter","ip","limiter","mergedHeaders","rate_limiter_middleware_default","createEdgeRouter","EdgeRouter","Router","withZod","BadGateway","BadRequest","BandwidthLimitExceeded","Conflict","default","ExpectationFailed","FailedDependency","Forbidden","GatewayTimeout","Gone","HTTPVersionNotSupported","ImATeapot","InsufficientStorage","InternalServerError","LengthRequired","Locked","LoopDetected","MethodNotAllowed","MisdirectedRequest","NetworkAuthenticationRequire","NotAcceptable","NotExtended","NotFound","NotImplemented","PayloadTooLarge","PaymentRequired","PreconditionFailed","PreconditionRequired","ProxyAuthenticationRequired","RangeNotSatisfiable","RequestHeaderFieldsTooLarge","RequestTimeout","ServiceUnavailable","TooManyRequests","Unauthorized","UnavailableForLegalReasons","UnprocessableEntity","UnsupportedMediaType","UpgradeRequired","URITooLong","VariantAlsoNegotiates"],"mappings":"yIAEA,OAAS,cAAAA,OAAkB,oBCC3B,OAAOC,MAAqB,cCH5B,OAAS,aAAAC,MAAiB,cAC1B,OAAS,mBAAAC,MAAuB,oBAChC,OAAOC,MAAY,UCCnB,OAAS,eAAAC,MAAmB,oBAErB,IAAMC,EAAkB,CAACC,EAA0BC,IAAyB,CAC/E,IAAMC,EAAoED,EAAoB,SAAW,CAAC,EAE1G,OAAO,KAAKC,CAAO,EAAE,QAASC,GAAmB,CAC7CH,EAAS,UAAUG,EAAQD,EAAQC,CAAM,CAA4C,CACzF,CAAC,CACL,EAOaC,EAAW,CAACJ,EAA0BK,IAA4B,CAE3EL,EAAS,UAAU,eAAgB,iCAAiC,EAEpEA,EAAS,IAAI,KAAK,UAAUK,CAAQ,CAAC,CACzC,EAEaC,EAA0B,CAACN,EAA0BC,IAAyB,CAGlFA,EAAoB,aAAe,SACpCD,EAAS,WAAcC,EAAoB,YAK1CA,EAAoB,SAAW,SAChCD,EAAS,WAAcC,EAAoB,QAI3CD,EAAS,WAAa,MACtBA,EAAS,WAAaF,EAAY,sBAE1C,EDnCA,IAAMS,EAAe,oBAEfC,EAAoC,CAACP,EAA6CQ,EAAUT,IAAa,CAK3G,GAJAM,EAAwBN,EAAUC,CAAK,EAEvCF,EAAgBC,EAAUC,CAAK,EAE3BA,aAAiBJ,EAAO,WAAaA,EAAO,UAAU,gBAAgBI,CAAK,EAAG,CAC9E,IAAMS,EAAa,IAAIb,EAAO,gBAE9BO,EAASJ,EAAUU,EAAW,UAAUT,CAAK,CAAC,CAClD,SAAWA,aAAiBN,EAAW,CACnC,GAAM,CAAE,QAAAgB,EAAS,WAAAC,EAA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,GAAkB,cAAAC,GAAY,kBAAAZ,GAAgB,cAAAlF,GAAY,UAAA+F,GAAQ,YAAApF,GAAU,WAAAqF,OAAe,oBACpG,OACI,cAAAC,GACA,cAAAC,GACA,0BAAAC,GACA,YAAAC,GACW,WAAXC,GACA,qBAAAC,GACA,oBAAAC,GACA,aAAAC,GACA,kBAAAC,GACA,QAAAC,GACA,2BAAAC,GACA,aAAAC,GACA,uBAAAC,GACA,uBAAAC,GACA,kBAAAC,GACA,UAAAC,GACA,gBAAAC,GACA,oBAAAC,GACA,sBAAAC,GACA,gCAAAC,GACA,iBAAAC,GACA,eAAAC,GACA,YAAAC,GACA,kBAAAC,GACA,mBAAAC,GACA,mBAAAC,GACA,sBAAAC,GACA,wBAAAC,GACA,+BAAAC,GACA,uBAAAC,GACA,+BAAAC,GACA,kBAAAC,GACA,sBAAAC,GACA,mBAAAC,GACA,gBAAAC,GACA,8BAAAC,GACA,uBAAAC,GACA,wBAAAC,GACA,mBAAAC,GACA,cAAAC,GACA,yBAAAC,OACG","sourcesContent":["import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { NodeRouter } from \"@visulima/connect\";\nimport type { AnyZodObject, ZodObject } from \"zod\";\n\nimport type { ErrorHandlers } from \"../error-handler/types\";\nimport type { Serializers } from \"../serializers\";\nimport { onError, onNoMatch } from \"./handler\";\nimport httpHeaderNormalizerMiddleware from \"./middleware/http-header-normalizer\";\nimport serializersMiddleware from \"./middleware/serializers-middleware\";\n\nconst createNodeRouter = <\n Request extends IncomingMessage,\n Response extends ServerResponse,\n Schema extends AnyZodObject = ZodObject<{ body?: AnyZodObject; headers?: AnyZodObject; query?: AnyZodObject }>,\n>(\n options: {\n errorHandlers?: ErrorHandlers;\n middlewares?: {\n \"http-header-normalizer\"?: { canonical?: boolean; normalizeHeaderKey?: (key: string, canonical: boolean) => string };\n serializers?: {\n defaultContentType?: string;\n serializers?: Serializers;\n };\n };\n showTrace?: boolean;\n } = {},\n): NodeRouter<Request, Response, Schema> => {\n const router = new NodeRouter<Request, Response, Schema>({\n onError: onError(options.errorHandlers ?? [], options.showTrace ?? false),\n onNoMatch,\n });\n\n return router\n .use(httpHeaderNormalizerMiddleware(options.middlewares?.[\"http-header-normalizer\"] ?? {}))\n .use(\n serializersMiddleware(\n options.middlewares?.serializers?.serializers ?? [],\n options.middlewares?.serializers?.defaultContentType ?? \"application/json; charset=utf-8\",\n ),\n );\n};\n\nexport default createNodeRouter;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport type { FunctionLike, Nextable, Route, ValueOrPromise } from \"@visulima/connect\";\nimport createHttpError from \"http-errors\";\n\nimport JsonapiErrorHandler from \"../error-handler/jsonapi-error-handler\";\nimport ProblemErrorHandler from \"../error-handler/problem-error-handler\";\nimport type { ErrorHandler, ErrorHandlers } from \"../error-handler/types\";\n\nexport const onError =\n <Request extends IncomingMessage, Response extends ServerResponse>(errorHandlers: ErrorHandlers, showTrace: boolean) =>\n async (error: unknown, request: Request, response: Response): Promise<void> => {\n const apiFormat: string = request.headers.accept as string;\n\n let errorHandler: ErrorHandler = ProblemErrorHandler;\n\n if (apiFormat === \"application/vnd.api+json\") {\n errorHandler = JsonapiErrorHandler;\n }\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const { handler, regex } of errorHandlers) {\n if (regex.test(apiFormat)) {\n errorHandler = handler;\n break;\n }\n }\n\n // eslint-disable-next-line no-param-reassign\n (error as Error & { expose: boolean }).expose = showTrace;\n\n errorHandler(error, request, response);\n };\n\nexport const onNoMatch: <Request extends IncomingMessage, Response extends ServerResponse>(\n request: Request,\n response: Response,\n routes: Route<Nextable<FunctionLike>>[],\n) => ValueOrPromise<void> = async (request, response, routes) => {\n const uniqueMethods = [...new Set(routes.map((route) => route.method))].join(\", \");\n\n response.setHeader(\"Allow\", uniqueMethods);\n response.statusCode = 405;\n\n throw createHttpError(405, `No route with [${request.method}] method found.`);\n};\n","import { HttpError } from \"http-errors\";\nimport { getReasonPhrase } from \"http-status-codes\";\nimport tsJapi from \"ts-japi\";\n\nimport type { ErrorHandler } from \"./types\";\nimport { addStatusCodeToResponse, sendJson, setErrorHeaders } from \"./utils\";\n\nconst defaultTitle = \"An error occurred\";\n\nconst jsonapiErrorHandler: ErrorHandler = (error: Error | HttpError | tsJapi.JapiError, _request, response) => {\n addStatusCodeToResponse(response, error);\n\n setErrorHeaders(response, error);\n\n if (error instanceof tsJapi.JapiError || tsJapi.JapiError.isLikeJapiError(error)) {\n const serializer = new tsJapi.ErrorSerializer();\n\n sendJson(response, serializer.serialize(error));\n } else if (error instanceof HttpError) {\n const { message, statusCode, title } = error;\n\n sendJson(response, {\n errors: [\n {\n code: statusCode,\n title: title || getReasonPhrase(statusCode) || defaultTitle,\n // eslint-disable-next-line perfectionist/sort-objects\n detail: message,\n },\n ],\n });\n } else {\n const { message } = error;\n\n sendJson(response, {\n errors: [\n {\n code: \"500\",\n title: getReasonPhrase(response.statusCode) || defaultTitle,\n // eslint-disable-next-line perfectionist/sort-objects\n detail: message,\n },\n ],\n });\n }\n};\n\nexport default jsonapiErrorHandler;\n","import type { ServerResponse } from \"node:http\";\n\nimport type { HttpError } from \"http-errors\";\nimport { StatusCodes } from \"http-status-codes\";\n\nexport const setErrorHeaders = (response: ServerResponse, error: unknown): void => {\n const headers: Record<string, ReadonlyArray<string> | number | string> = (error as HttpError).headers ?? {};\n\n Object.keys(headers).forEach((header: string) => {\n response.setHeader(header, headers[header] as ReadonlyArray<string> | number | string);\n });\n};\n\n/**\n * Send `JSON` object\n * @param response response object\n * @param jsonBody of data\n */\nexport const sendJson = (response: ServerResponse, jsonBody: unknown): void => {\n // Set header to application/json\n response.setHeader(\"content-type\", \"application/json; charset=utf-8\");\n\n response.end(JSON.stringify(jsonBody));\n};\n\nexport const addStatusCodeToResponse = (response: ServerResponse, error: unknown): void => {\n // respect err.statusCode\n\n if ((error as HttpError).statusCode !== undefined) {\n response.statusCode = (error as HttpError).statusCode;\n }\n\n // respect err.status\n\n if ((error as HttpError).status !== undefined) {\n response.statusCode = (error as HttpError).status;\n }\n\n // default status code to 500\n if (response.statusCode < 400) {\n response.statusCode = StatusCodes.INTERNAL_SERVER_ERROR;\n }\n};\n","import { HttpError } from \"http-errors\";\nimport { getReasonPhrase } from \"http-status-codes\";\n\nimport type { ErrorHandler } from \"./types\";\nimport { addStatusCodeToResponse, sendJson, setErrorHeaders } from \"./utils\";\n\nconst defaultType = \"https://tools.ietf.org/html/rfc2616#section-10\";\nconst defaultTitle = \"An error occurred\";\n/**\n * Normalizes errors according to the API Problem spec (RFC 7807).\n *\n * @see https://tools.ietf.org/html/rfc7807\n */\nconst problemErrorHandler: ErrorHandler = (error: Error | HttpError, _request, response) => {\n const { message, stack } = error;\n\n if (error instanceof HttpError) {\n const { expose, statusCode, title, type } = error;\n\n response.statusCode = statusCode;\n\n setErrorHeaders(response, error);\n\n sendJson(response, {\n type: type || defaultType,\n // eslint-disable-next-line perfectionist/sort-objects\n title: title || getReasonPhrase(statusCode) || defaultTitle,\n // eslint-disable-next-line perfectionist/sort-objects\n details: message,\n ...(expose ? { trace: stack } : {}),\n });\n } else {\n addStatusCodeToResponse(response, error);\n\n sendJson(response, {\n type: defaultType,\n // eslint-disable-next-line perfectionist/sort-objects\n title: getReasonPhrase(response.statusCode) || defaultTitle,\n // eslint-disable-next-line perfectionist/sort-objects\n details: message,\n ...((error as Error & { expose: boolean }).expose ? { trace: stack } : {}),\n });\n }\n};\n\nexport default problemErrorHandler;\n","import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from \"node:http\";\n\nimport type { NextHandler, ValueOrPromise } from \"@visulima/connect\";\n\nconst exceptions = {\n alpn: \"ALPN\",\n \"c-pep\": \"C-PEP\",\n \"c-pep-info\": \"C-PEP-Info\",\n \"caldav-timezones\": \"CalDAV-Timezones\",\n \"content-id\": \"Content-ID\",\n \"content-md5\": \"Content-MD5\",\n dasl: \"DASL\",\n dav: \"DAV\",\n dnt: \"DNT\",\n etag: \"ETag\",\n getprofile: \"GetProfile\",\n \"http2-settings\": \"HTTP2-Settings\",\n \"last-event-id\": \"Last-Event-ID\",\n \"mime-version\": \"MIME-Version\",\n \"optional-www-authenticate\": \"Optional-WWW-Authenticate\",\n \"sec-webSocket-key\": \"Sec-WebSocket-Key\",\n \"sec-webSocket-protocol\": \"Sec-WebSocket-Protocol\",\n \"sec-webSocket-version\": \"Sec-WebSocket-Version\",\n \"sec-websocket-accept\": \"Sec-WebSocket-Accept\",\n \"sec-websocket-extensions\": \"Sec-WebSocket-Extensions\",\n slug: \"SLUG\",\n tcn: \"TCN\",\n te: \"TE\",\n ttl: \"TTL\",\n \"www-authenticate\": \"WWW-Authenticate\",\n \"x-att-deviceid\": \"X-ATT-DeviceId\",\n \"x-dnsprefetch-control\": \"X-DNSPrefetch-Control\",\n \"x-uidh\": \"X-UIDH\",\n};\n\nconst normalizeHeaderKey = (key: string, canonical: boolean) => {\n const lowerCaseKey = key.toLowerCase();\n\n if (!canonical) {\n return lowerCaseKey;\n }\n\n if (exceptions[lowerCaseKey as keyof typeof exceptions]) {\n return exceptions[lowerCaseKey as keyof typeof exceptions];\n }\n\n return (\n lowerCaseKey\n .split(\"-\")\n // eslint-disable-next-line no-unsafe-optional-chaining\n .map((text: string) => text[0]?.toUpperCase() + text.slice(1))\n .join(\"-\")\n );\n};\n\nconst defaults = {\n canonical: false,\n normalizeHeaderKey,\n};\n\n/**\n * HTTP headers are case-insensitive.\n * That's why NodeJS makes them lower case by default.\n * While sensible, sometimes, for example for compatibility reasons, you might need them in their more common form.\n */\nconst httpHeaderNormalizerMiddleware = (options_?: {\n canonical?: boolean;\n normalizeHeaderKey?: (key: string, canonical: boolean) => string;\n}): ((request: IncomingMessage, response: ServerResponse, next: NextHandler) => ValueOrPromise<void>) => {\n const options = { ...defaults, ...options_ };\n\n return async <Request extends IncomingMessage>(request: Request, _: any, next: NextHandler) => {\n const rawHeaders: IncomingHttpHeaders = {};\n const headers: IncomingHttpHeaders = {};\n\n Object.keys(request.headers).forEach((key) => {\n rawHeaders[key] = request.headers[key];\n\n const normalizedKey = options.normalizeHeaderKey(key, options.canonical);\n\n if (normalizedKey) {\n headers[normalizedKey] = request.headers[key];\n }\n });\n\n request.headers = headers;\n // @TODO at type `request.rawHeaders` to global scope\n // @ts-expect-error - `rawHeaders` is not a property of `Request`\n request.rawHeaders = rawHeaders;\n\n return next();\n };\n};\n\nexport default httpHeaderNormalizerMiddleware;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport type { NextHandler, ValueOrPromise } from \"@visulima/connect\";\nimport debug from \"debug\";\nimport type { NextApiResponse } from \"next/types\";\n\nimport type { Serializers } from \"../../serializers\";\nimport { serialize } from \"../../serializers\";\n\nconst log = debug(\"api-platform:connect:serializers-middleware\");\n\nconst serializersMiddleware =\n (serializers: Serializers = [], defaultContentType = \"application/json; charset=utf-8\") =>\n async <Request extends IncomingMessage, Response extends ServerResponse>(\n request: Request,\n response: NextApiResponse | Response,\n next: NextHandler,\n ): Promise<ValueOrPromise<void>> => {\n if (typeof (response as NextApiResponse).send === \"function\") {\n const oldSend = (response as NextApiResponse).send;\n\n (response as NextApiResponse).send = (data) => {\n (response as NextApiResponse).send = oldSend;\n\n // eslint-disable-next-line no-param-reassign\n data = serialize<Request, NextApiResponse | Response>(serializers, request, response, data, { defaultContentType });\n\n (response as NextApiResponse).send(data);\n };\n } else if (typeof (response as NextApiResponse).json === \"function\") {\n log(\"response.json() is not supported by @visulima/api-platform serializer. Use response.send() or response.end() instead.\");\n } else {\n const oldEnd = response.end;\n\n // @ts-expect-error TS2322: Type\n (response as Response).end = (data, ...arguments_) => {\n response.end = oldEnd;\n\n // eslint-disable-next-line no-param-reassign\n data = serialize<Request, NextApiResponse | Response>(serializers, request, response, data, { defaultContentType });\n\n // @ts-expect-error TS2345: Argument of type 'unknown' is not assignable to parameter of type 'BufferEncoding'.\n return response.end(data, ...arguments_);\n };\n }\n\n return next();\n };\n\nexport default serializersMiddleware;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport accepts from \"accepts\";\n\nimport { toHeaderCase } from \"../utils\";\nimport hasJsonStructure from \"./has-json-structure\";\nimport xmlTransformer from \"./transformer/xml\";\nimport yamlTransformer from \"./transformer/yaml\";\nimport type { Serializers } from \"./types\";\n\nconst contentTypeKey = \"Content-Type\";\n\nconst serialize = <Request extends IncomingMessage, Response extends ServerResponse>(\n serializers: Serializers,\n request: Request,\n response: Response,\n data: unknown,\n options: {\n defaultContentType: string;\n },\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Buffer | Uint8Array | string => {\n const contentType = response.getHeader(contentTypeKey) as string | undefined;\n\n // skip serialization when Content-Type is already set\n if (typeof contentType === \"string\") {\n return data as string;\n }\n\n const accept = accepts(request);\n const types: string[] = [...(accept.types() as string[]), options.defaultContentType];\n\n let serializedData = data;\n let breakTypes = false;\n\n types.forEach((type) => {\n serializers.forEach(({ regex, serializer }) => {\n if (regex.test(type)) {\n response.setHeader(contentTypeKey, type);\n\n serializedData = serializer(serializedData);\n breakTypes = true;\n }\n });\n\n if (!breakTypes) {\n if (/yaml|yml/.test(type)) {\n response.setHeader(contentTypeKey, type);\n\n serializedData = yamlTransformer(hasJsonStructure(data) ? JSON.parse(data as string) : data);\n } else if (type.includes(\"xml\")) {\n response.setHeader(contentTypeKey, type);\n\n serializedData = xmlTransformer({\n [toHeaderCase(`${request.url?.replace(\"/api/\", \"\")}`.trim())]: hasJsonStructure(data) ? JSON.parse(data as string) : data,\n });\n }\n }\n });\n\n return serializedData as Buffer | Uint8Array | string;\n};\n\nexport default serialize;\n","const hasJsonStructure = (data: unknown): boolean => {\n if (typeof data !== \"string\") {\n return false;\n }\n\n try {\n const result = JSON.parse(data);\n const type = Object.prototype.toString.call(result);\n\n return type === \"[object Object]\" || type === \"[object Array]\";\n } catch {\n return false;\n }\n};\n\nexport default hasJsonStructure;\n","import type { XmlElement } from \"jstoxml\";\nimport { toXML } from \"jstoxml\";\n\nimport type { Serializer } from \"../types\";\n\nconst xmlTransformer: Serializer = (data?: XmlElement | XmlElement[]) =>\n toXML(data, {\n header: true,\n indent: \" \",\n });\n\nexport default xmlTransformer;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { expressWrapper } from \"@visulima/connect\";\nimport type { CorsOptions, CorsOptionsDelegate } from \"cors\";\nimport cors from \"cors\";\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nconst corsMiddleware = <Request extends IncomingMessage, Response extends ServerResponse>(options?: CorsOptions | CorsOptionsDelegate) =>\n expressWrapper<Request, Response>(cors(options));\n\nexport default corsMiddleware;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport type { NextHandler } from \"@visulima/connect\";\nimport createHttpError from \"http-errors\";\nimport type { NextApiResponse } from \"next/types\";\nimport type { RateLimiterAbstract, RateLimiterRes } from \"rate-limiter-flexible\";\n\nconst getIP: (request: IncomingMessage & { ip?: string }) => string | undefined = (request) =>\n request.ip ??\n (request.headers[\"x-forwarded-for\"] as string | undefined) ??\n (request.headers[\"x-real-ip\"] as string | undefined) ??\n request.socket.remoteAddress;\n\ntype HeaderValue = ReadonlyArray<string> | number | string;\n\nconst rateLimiterMiddleware =\n (rateLimiter: RateLimiterAbstract, headers?: (limiterResponse: RateLimiterRes) => Record<string, HeaderValue>) =>\n async <Request extends IncomingMessage, Response extends ServerResponse>(\n request: Request,\n response: NextApiResponse | Response,\n next: NextHandler,\n ): Promise<void> => {\n const ip = getIP(request);\n\n if (ip === undefined) {\n throw createHttpError(400, \"Missing IP\");\n }\n\n try {\n const limiter = await rateLimiter.consume(ip);\n\n const mergedHeaders: Record<string, HeaderValue> = {\n \"Retry-After\": Math.round(limiter.msBeforeNext / 1000) || 1,\n \"X-RateLimit-Remaining\": limiter.remainingPoints,\n \"X-RateLimit-Reset\": new Date(Date.now() + limiter.msBeforeNext).toISOString(),\n ...headers,\n };\n\n Object.keys(mergedHeaders).forEach((key) => {\n response.setHeader(key, mergedHeaders[key] as HeaderValue);\n });\n\n await next();\n } catch {\n throw createHttpError(429, \"Too Many Requests\");\n }\n };\n\nexport default rateLimiterMiddleware;\n","export { default as createNodeRouter } from \"./connect/create-node-router\";\nexport { onError, onNoMatch } from \"./connect/handler\";\nexport { default as corsMiddleware } from \"./connect/middleware/cors-middleware\";\nexport { default as httpHeaderNormalizerMiddleware } from \"./connect/middleware/http-header-normalizer\";\nexport { default as rateLimiterMiddleware } from \"./connect/middleware/rate-limiter-middleware\";\nexport { default as serializersMiddleware } from \"./connect/middleware/serializers-middleware\";\nexport * from \"./index-browser\";\nexport type { Serializer, Serializers } from \"./serializers\";\nexport { serialize, xmlTransformer, yamlTransformer } from \"./serializers\";\nexport { default as swaggerHandler } from \"./swagger/api/swagger-handler\";\nexport { dateIn, dateOut } from \"./zod\";\nexport type {\n EdgeRequestHandler,\n ExpressRequestHandler,\n FindResult,\n FunctionLike,\n HandlerOptions,\n HttpMethod,\n Nextable,\n NextHandler,\n NodeRequestHandler,\n Route,\n RouteShortcutMethod,\n ValueOrPromise,\n} from \"@visulima/connect\";\nexport { createEdgeRouter, EdgeRouter, expressWrapper, NodeRouter, Router, sendJson, withZod } from \"@visulima/connect\";\nexport {\n BadGateway,\n BadRequest,\n BandwidthLimitExceeded,\n Conflict,\n default as createHttpError,\n ExpectationFailed,\n FailedDependency,\n Forbidden,\n GatewayTimeout,\n Gone,\n HTTPVersionNotSupported,\n ImATeapot,\n InsufficientStorage,\n InternalServerError,\n LengthRequired,\n Locked,\n LoopDetected,\n MethodNotAllowed,\n MisdirectedRequest,\n NetworkAuthenticationRequire,\n NotAcceptable,\n NotExtended,\n NotFound,\n NotImplemented,\n PayloadTooLarge,\n PaymentRequired,\n PreconditionFailed,\n PreconditionRequired,\n ProxyAuthenticationRequired,\n RangeNotSatisfiable,\n RequestHeaderFieldsTooLarge,\n RequestTimeout,\n ServiceUnavailable,\n TooManyRequests,\n Unauthorized,\n UnavailableForLegalReasons,\n UnprocessableEntity,\n UnsupportedMediaType,\n UpgradeRequired,\n URITooLong,\n VariantAlsoNegotiates,\n} from \"http-errors\";\n"]}
1
+ {"version":3,"sources":["../src/error-handler/utils.ts","../src/error-handler/jsonapi-error-handler.ts","../src/error-handler/problem-error-handler.ts","../src/connect/handler.ts","../src/connect/middleware/http-header-normalizer.ts","../src/serializers/has-json-structure.ts","../src/serializers/transformer/xml.ts","../src/serializers/serialize.ts","../src/connect/middleware/serializers-middleware.ts","../src/connect/create-node-router.ts","../src/connect/middleware/cors-middleware.ts","../src/connect/middleware/rate-limiter-middleware.ts"],"names":["setErrorHeaders","response","error","headers","header","sendJson","jsonBody","addStatusCodeToResponse","StatusCodes","defaultTitle","jsonapiErrorHandler","_request","tsJapi","serializer","HttpError","message","statusCode","title","getReasonPhrase","jsonapi_error_handler_default","defaultType","problemErrorHandler","stack","expose","type","problem_error_handler_default","onError","errorHandlers","showTrace","request","apiFormat","errorHandler","handler","regex","onNoMatch","routes","uniqueMethods","route","createHttpError","exceptions","normalizeHeaderKey","key","canonical","lowerCaseKey","text","defaults","httpHeaderNormalizerMiddleware","options_","options","_","next","rawHeaders","normalizedKey","http_header_normalizer_default","hasJsonStructure","data","result","has_json_structure_default","xmlTransformer","toXML","xml_default","contentTypeKey","serialize","serializers","types","accepts","serializedData","breakTypes","yaml_default","toHeaderCase","serialize_default","log","debug","serializersMiddleware","defaultContentType","oldSend","oldEnd","arguments_","serializers_middleware_default","createNodeRouter","NodeRouter","create_node_router_default","corsMiddleware","expressWrapper","cors","cors_middleware_default","getIP","rateLimiterMiddleware","rateLimiter","ip","limiter","mergedHeaders","rate_limiter_middleware_default"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAKO,IAAMA,CAAkB,CAAA,CAACC,CAA0BC,CAAAA,CAAAA,GAAyB,CAC/E,IAAMC,CAAoED,CAAAA,CAAAA,CAAoB,SAAW,EAAC,CAE1G,MAAO,CAAA,IAAA,CAAKC,CAAO,CAAA,CAAE,OAASC,CAAAA,CAAAA,EAAmB,CAC7CH,CAAAA,CAAS,SAAUG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,IAAMoD,EAAU,MAAMF,CAAAA,CAAY,OAAQC,CAAAA,CAAE,CAEtCE,CAAAA,CAAAA,CAA6C,CAC/C,aAAA,CAAe,KAAK,KAAMD,CAAAA,CAAAA,CAAQ,YAAe,CAAA,GAAI,CAAK,EAAA,CAAA,CAC1D,uBAAyBA,CAAAA,CAAAA,CAAQ,gBACjC,mBAAqB,CAAA,IAAI,IAAK,CAAA,IAAA,CAAK,GAAI,EAAA,CAAIA,CAAQ,CAAA,YAAY,CAAE,CAAA,WAAA,EACjE,CAAA,GAAGvF,CACP,CAAA,CAEA,MAAO,CAAA,IAAA,CAAKwF,CAAa,CAAE,CAAA,OAAA,CAASlD,CAAQ,EAAA,CACxCxC,CAAS,CAAA,SAAA,CAAUwC,CAAKkD,CAAAA,CAAAA,CAAclD,CAAG,CAAgB,EAC7D,CAAC,CAAA,CAED,MAAMS,CAAAA,GACV,CAAA,KAAQ,CACJ,MAAMZ,kBAAAA,CAAgB,GAAK,CAAA,mBAAmB,CAClD,CACJ,CAEGsD,CAAAA,EAAAA,CAAQL","file":"index-server.js","sourcesContent":["import type { ServerResponse } from \"node:http\";\n\nimport type { HttpError } from \"http-errors\";\nimport { StatusCodes } from \"http-status-codes\";\n\nexport const setErrorHeaders = (response: ServerResponse, error: unknown): void => {\n const headers: Record<string, ReadonlyArray<string> | number | string> = (error as HttpError).headers ?? {};\n\n Object.keys(headers).forEach((header: string) => {\n response.setHeader(header, headers[header] as ReadonlyArray<string> | number | string);\n });\n};\n\n/**\n * Send `JSON` object\n * @param response response object\n * @param jsonBody of data\n */\nexport const sendJson = (response: ServerResponse, jsonBody: unknown): void => {\n // Set header to application/json\n response.setHeader(\"content-type\", \"application/json; charset=utf-8\");\n\n response.end(JSON.stringify(jsonBody));\n};\n\nexport const addStatusCodeToResponse = (response: ServerResponse, error: unknown): void => {\n // respect err.statusCode\n\n if ((error as HttpError).statusCode !== undefined) {\n response.statusCode = (error as HttpError).statusCode;\n }\n\n // respect err.status\n\n if ((error as HttpError).status !== undefined) {\n response.statusCode = (error as HttpError).status;\n }\n\n // default status code to 500\n if (response.statusCode < 400) {\n response.statusCode = StatusCodes.INTERNAL_SERVER_ERROR;\n }\n};\n","import { HttpError } from \"http-errors\";\nimport { getReasonPhrase } from \"http-status-codes\";\nimport tsJapi from \"ts-japi\";\n\nimport type { ErrorHandler } from \"./types\";\nimport { addStatusCodeToResponse, sendJson, setErrorHeaders } from \"./utils\";\n\nconst defaultTitle = \"An error occurred\";\n\nconst jsonapiErrorHandler: ErrorHandler = (error: Error | HttpError | tsJapi.JapiError, _request, response) => {\n addStatusCodeToResponse(response, error);\n\n setErrorHeaders(response, error);\n\n if (error instanceof tsJapi.JapiError || tsJapi.JapiError.isLikeJapiError(error)) {\n const serializer = new tsJapi.ErrorSerializer();\n\n sendJson(response, serializer.serialize(error));\n } else if (error instanceof HttpError) {\n const { message, statusCode, title } = error;\n\n sendJson(response, {\n errors: [\n {\n code: statusCode,\n title: title || getReasonPhrase(statusCode) || defaultTitle,\n // eslint-disable-next-line perfectionist/sort-objects\n detail: message,\n },\n ],\n });\n } else {\n const { message } = error;\n\n sendJson(response, {\n errors: [\n {\n code: \"500\",\n title: getReasonPhrase(response.statusCode) || defaultTitle,\n // eslint-disable-next-line perfectionist/sort-objects\n detail: message,\n },\n ],\n });\n }\n};\n\nexport default jsonapiErrorHandler;\n","import { HttpError } from \"http-errors\";\nimport { getReasonPhrase } from \"http-status-codes\";\n\nimport type { ErrorHandler } from \"./types\";\nimport { addStatusCodeToResponse, sendJson, setErrorHeaders } from \"./utils\";\n\nconst defaultType = \"https://tools.ietf.org/html/rfc2616#section-10\";\nconst defaultTitle = \"An error occurred\";\n/**\n * Normalizes errors according to the API Problem spec (RFC 7807).\n *\n * @see https://tools.ietf.org/html/rfc7807\n */\nconst problemErrorHandler: ErrorHandler = (error: Error | HttpError, _request, response) => {\n const { message, stack } = error;\n\n if (error instanceof HttpError) {\n const { expose, statusCode, title, type } = error;\n\n response.statusCode = statusCode;\n\n setErrorHeaders(response, error);\n\n sendJson(response, {\n type: type || defaultType,\n // eslint-disable-next-line perfectionist/sort-objects\n title: title || getReasonPhrase(statusCode) || defaultTitle,\n // eslint-disable-next-line perfectionist/sort-objects\n details: message,\n ...(expose ? { trace: stack } : {}),\n });\n } else {\n addStatusCodeToResponse(response, error);\n\n sendJson(response, {\n type: defaultType,\n // eslint-disable-next-line perfectionist/sort-objects\n title: getReasonPhrase(response.statusCode) || defaultTitle,\n // eslint-disable-next-line perfectionist/sort-objects\n details: message,\n ...((error as Error & { expose: boolean }).expose ? { trace: stack } : {}),\n });\n }\n};\n\nexport default problemErrorHandler;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport type { FunctionLike, Nextable, Route, ValueOrPromise } from \"@visulima/connect\";\nimport createHttpError from \"http-errors\";\n\nimport JsonapiErrorHandler from \"../error-handler/jsonapi-error-handler\";\nimport ProblemErrorHandler from \"../error-handler/problem-error-handler\";\nimport type { ErrorHandler, ErrorHandlers } from \"../error-handler/types\";\n\nexport const onError =\n <Request extends IncomingMessage, Response extends ServerResponse>(errorHandlers: ErrorHandlers, showTrace: boolean) =>\n async (error: unknown, request: Request, response: Response): Promise<void> => {\n const apiFormat: string = request.headers.accept as string;\n\n let errorHandler: ErrorHandler = ProblemErrorHandler;\n\n if (apiFormat === \"application/vnd.api+json\") {\n errorHandler = JsonapiErrorHandler;\n }\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const { handler, regex } of errorHandlers) {\n if (regex.test(apiFormat)) {\n errorHandler = handler;\n break;\n }\n }\n\n // eslint-disable-next-line no-param-reassign\n (error as Error & { expose: boolean }).expose = showTrace;\n\n errorHandler(error, request, response);\n };\n\nexport const onNoMatch: <Request extends IncomingMessage, Response extends ServerResponse>(\n request: Request,\n response: Response,\n routes: Route<Nextable<FunctionLike>>[],\n) => ValueOrPromise<void> = async (request, response, routes) => {\n const uniqueMethods = [...new Set(routes.map((route) => route.method))].join(\", \");\n\n response.setHeader(\"Allow\", uniqueMethods);\n response.statusCode = 405;\n\n throw createHttpError(405, `No route with [${request.method}] method found.`);\n};\n","import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from \"node:http\";\n\nimport type { NextHandler, ValueOrPromise } from \"@visulima/connect\";\n\nconst exceptions = {\n alpn: \"ALPN\",\n \"c-pep\": \"C-PEP\",\n \"c-pep-info\": \"C-PEP-Info\",\n \"caldav-timezones\": \"CalDAV-Timezones\",\n \"content-id\": \"Content-ID\",\n \"content-md5\": \"Content-MD5\",\n dasl: \"DASL\",\n dav: \"DAV\",\n dnt: \"DNT\",\n etag: \"ETag\",\n getprofile: \"GetProfile\",\n \"http2-settings\": \"HTTP2-Settings\",\n \"last-event-id\": \"Last-Event-ID\",\n \"mime-version\": \"MIME-Version\",\n \"optional-www-authenticate\": \"Optional-WWW-Authenticate\",\n \"sec-webSocket-key\": \"Sec-WebSocket-Key\",\n \"sec-webSocket-protocol\": \"Sec-WebSocket-Protocol\",\n \"sec-webSocket-version\": \"Sec-WebSocket-Version\",\n \"sec-websocket-accept\": \"Sec-WebSocket-Accept\",\n \"sec-websocket-extensions\": \"Sec-WebSocket-Extensions\",\n slug: \"SLUG\",\n tcn: \"TCN\",\n te: \"TE\",\n ttl: \"TTL\",\n \"www-authenticate\": \"WWW-Authenticate\",\n \"x-att-deviceid\": \"X-ATT-DeviceId\",\n \"x-dnsprefetch-control\": \"X-DNSPrefetch-Control\",\n \"x-uidh\": \"X-UIDH\",\n};\n\nconst normalizeHeaderKey = (key: string, canonical: boolean) => {\n const lowerCaseKey = key.toLowerCase();\n\n if (!canonical) {\n return lowerCaseKey;\n }\n\n if (exceptions[lowerCaseKey as keyof typeof exceptions]) {\n return exceptions[lowerCaseKey as keyof typeof exceptions];\n }\n\n return (\n lowerCaseKey\n .split(\"-\")\n // eslint-disable-next-line no-unsafe-optional-chaining\n .map((text: string) => text[0]?.toUpperCase() + text.slice(1))\n .join(\"-\")\n );\n};\n\nconst defaults = {\n canonical: false,\n normalizeHeaderKey,\n};\n\n/**\n * HTTP headers are case-insensitive.\n * That's why NodeJS makes them lower case by default.\n * While sensible, sometimes, for example for compatibility reasons, you might need them in their more common form.\n */\nconst httpHeaderNormalizerMiddleware = (options_?: {\n canonical?: boolean;\n normalizeHeaderKey?: (key: string, canonical: boolean) => string;\n}): ((request: IncomingMessage, response: ServerResponse, next: NextHandler) => ValueOrPromise<void>) => {\n const options = { ...defaults, ...options_ };\n\n return async <Request extends IncomingMessage>(request: Request, _: any, next: NextHandler) => {\n const rawHeaders: IncomingHttpHeaders = {};\n const headers: IncomingHttpHeaders = {};\n\n Object.keys(request.headers).forEach((key) => {\n rawHeaders[key] = request.headers[key];\n\n const normalizedKey = options.normalizeHeaderKey(key, options.canonical);\n\n if (normalizedKey) {\n headers[normalizedKey] = request.headers[key];\n }\n });\n\n request.headers = headers;\n // @TODO at type `request.rawHeaders` to global scope\n // @ts-expect-error - `rawHeaders` is not a property of `Request`\n request.rawHeaders = rawHeaders;\n\n return next();\n };\n};\n\nexport default httpHeaderNormalizerMiddleware;\n","const hasJsonStructure = (data: unknown): boolean => {\n if (typeof data !== \"string\") {\n return false;\n }\n\n try {\n const result = JSON.parse(data);\n const type = Object.prototype.toString.call(result);\n\n return type === \"[object Object]\" || type === \"[object Array]\";\n } catch {\n return false;\n }\n};\n\nexport default hasJsonStructure;\n","import type { XmlElement } from \"jstoxml\";\nimport { toXML } from \"jstoxml\";\n\nimport type { Serializer } from \"../types\";\n\nconst xmlTransformer: Serializer = (data?: XmlElement | XmlElement[]) =>\n toXML(data, {\n header: true,\n indent: \" \",\n });\n\nexport default xmlTransformer;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport accepts from \"accepts\";\n\nimport { toHeaderCase } from \"../utils\";\nimport hasJsonStructure from \"./has-json-structure\";\nimport xmlTransformer from \"./transformer/xml\";\nimport yamlTransformer from \"./transformer/yaml\";\nimport type { Serializers } from \"./types\";\n\nconst contentTypeKey = \"Content-Type\";\n\nconst serialize = <Request extends IncomingMessage, Response extends ServerResponse>(\n serializers: Serializers,\n request: Request,\n response: Response,\n data: unknown,\n options: {\n defaultContentType: string;\n },\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): Buffer | Uint8Array | string => {\n const contentType = response.getHeader(contentTypeKey) as string | undefined;\n\n // skip serialization when Content-Type is already set\n if (typeof contentType === \"string\") {\n return data as string;\n }\n\n const accept = accepts(request);\n const types: string[] = [...(accept.types() as string[]), options.defaultContentType];\n\n let serializedData = data;\n let breakTypes = false;\n\n types.forEach((type) => {\n serializers.forEach(({ regex, serializer }) => {\n if (regex.test(type)) {\n response.setHeader(contentTypeKey, type);\n\n serializedData = serializer(serializedData);\n breakTypes = true;\n }\n });\n\n if (!breakTypes) {\n if (/yaml|yml/.test(type)) {\n response.setHeader(contentTypeKey, type);\n\n serializedData = yamlTransformer(hasJsonStructure(data) ? JSON.parse(data as string) : data);\n } else if (type.includes(\"xml\")) {\n response.setHeader(contentTypeKey, type);\n\n serializedData = xmlTransformer({\n [toHeaderCase(`${request.url?.replace(\"/api/\", \"\")}`.trim())]: hasJsonStructure(data) ? JSON.parse(data as string) : data,\n });\n }\n }\n });\n\n return serializedData as Buffer | Uint8Array | string;\n};\n\nexport default serialize;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport type { NextHandler, ValueOrPromise } from \"@visulima/connect\";\nimport debug from \"debug\";\nimport type { NextApiResponse } from \"next/types\";\n\nimport type { Serializers } from \"../../serializers\";\nimport { serialize } from \"../../serializers\";\n\nconst log = debug(\"api-platform:connect:serializers-middleware\");\n\nconst serializersMiddleware =\n (serializers: Serializers = [], defaultContentType = \"application/json; charset=utf-8\") =>\n async <Request extends IncomingMessage, Response extends ServerResponse>(\n request: Request,\n response: NextApiResponse | Response,\n next: NextHandler,\n ): Promise<ValueOrPromise<void>> => {\n if (typeof (response as NextApiResponse).send === \"function\") {\n const oldSend = (response as NextApiResponse).send;\n\n (response as NextApiResponse).send = (data) => {\n (response as NextApiResponse).send = oldSend;\n\n // eslint-disable-next-line no-param-reassign\n data = serialize<Request, NextApiResponse | Response>(serializers, request, response, data, { defaultContentType });\n\n (response as NextApiResponse).send(data);\n };\n } else if (typeof (response as NextApiResponse).json === \"function\") {\n log(\"response.json() is not supported by @visulima/api-platform serializer. Use response.send() or response.end() instead.\");\n } else {\n const oldEnd = response.end;\n\n // @ts-expect-error TS2322: Type\n (response as Response).end = (data, ...arguments_) => {\n response.end = oldEnd;\n\n // eslint-disable-next-line no-param-reassign\n data = serialize<Request, NextApiResponse | Response>(serializers, request, response, data, { defaultContentType });\n\n // @ts-expect-error TS2345: Argument of type 'unknown' is not assignable to parameter of type 'BufferEncoding'.\n return response.end(data, ...arguments_);\n };\n }\n\n return next();\n };\n\nexport default serializersMiddleware;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { NodeRouter } from \"@visulima/connect\";\nimport type { AnyZodObject, ZodObject } from \"zod\";\n\nimport type { ErrorHandlers } from \"../error-handler/types\";\nimport type { Serializers } from \"../serializers\";\nimport { onError, onNoMatch } from \"./handler\";\nimport httpHeaderNormalizerMiddleware from \"./middleware/http-header-normalizer\";\nimport serializersMiddleware from \"./middleware/serializers-middleware\";\n\nconst createNodeRouter = <\n Request extends IncomingMessage,\n Response extends ServerResponse,\n Schema extends AnyZodObject = ZodObject<{ body?: AnyZodObject; headers?: AnyZodObject; query?: AnyZodObject }>,\n>(\n options: {\n errorHandlers?: ErrorHandlers;\n middlewares?: {\n \"http-header-normalizer\"?: { canonical?: boolean; normalizeHeaderKey?: (key: string, canonical: boolean) => string };\n serializers?: {\n defaultContentType?: string;\n serializers?: Serializers;\n };\n };\n showTrace?: boolean;\n } = {},\n): NodeRouter<Request, Response, Schema> => {\n const router = new NodeRouter<Request, Response, Schema>({\n onError: onError(options.errorHandlers ?? [], options.showTrace ?? false),\n onNoMatch,\n });\n\n return router\n .use(httpHeaderNormalizerMiddleware(options.middlewares?.[\"http-header-normalizer\"] ?? {}))\n .use(\n serializersMiddleware(\n options.middlewares?.serializers?.serializers ?? [],\n options.middlewares?.serializers?.defaultContentType ?? \"application/json; charset=utf-8\",\n ),\n );\n};\n\nexport default createNodeRouter;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { expressWrapper } from \"@visulima/connect\";\nimport type { CorsOptions, CorsOptionsDelegate } from \"cors\";\nimport cors from \"cors\";\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nconst corsMiddleware = <Request extends IncomingMessage, Response extends ServerResponse>(options?: CorsOptions | CorsOptionsDelegate) =>\n expressWrapper<Request, Response>(cors(options));\n\nexport default corsMiddleware;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport type { NextHandler } from \"@visulima/connect\";\nimport createHttpError from \"http-errors\";\nimport type { NextApiResponse } from \"next/types\";\nimport type { RateLimiterAbstract, RateLimiterRes } from \"rate-limiter-flexible\";\n\nconst getIP: (request: IncomingMessage & { ip?: string }) => string | undefined = (request) =>\n request.ip ??\n (request.headers[\"x-forwarded-for\"] as string | undefined) ??\n (request.headers[\"x-real-ip\"] as string | undefined) ??\n request.socket.remoteAddress;\n\ntype HeaderValue = ReadonlyArray<string> | number | string;\n\nconst rateLimiterMiddleware =\n (rateLimiter: RateLimiterAbstract, headers?: (limiterResponse: RateLimiterRes) => Record<string, HeaderValue>) =>\n async <Request extends IncomingMessage, Response extends ServerResponse>(\n request: Request,\n response: NextApiResponse | Response,\n next: NextHandler,\n ): Promise<void> => {\n const ip = getIP(request);\n\n if (ip === undefined) {\n throw createHttpError(400, \"Missing IP\");\n }\n\n try {\n const limiter = await rateLimiter.consume(ip);\n\n const mergedHeaders: Record<string, HeaderValue> = {\n \"Retry-After\": Math.round(limiter.msBeforeNext / 1000) || 1,\n \"X-RateLimit-Remaining\": limiter.remainingPoints,\n \"X-RateLimit-Reset\": new Date(Date.now() + limiter.msBeforeNext).toISOString(),\n ...headers,\n };\n\n Object.keys(mergedHeaders).forEach((key) => {\n response.setHeader(key, mergedHeaders[key] as HeaderValue);\n });\n\n await next();\n } catch {\n throw createHttpError(429, \"Too Many Requests\");\n }\n };\n\nexport default rateLimiterMiddleware;\n"]}
@@ -16,5 +16,5 @@ import de from 'cors';
16
16
  var R=(e,o)=>{let t=o.headers??{};Object.keys(t).forEach(r=>{e.setHeader(r,t[r]);});},c=(e,o)=>{e.setHeader("content-type","application/json; charset=utf-8"),e.end(JSON.stringify(o));},y=(e,o)=>{o.statusCode!==void 0&&(e.statusCode=o.statusCode),o.status!==void 0&&(e.statusCode=o.status),e.statusCode<400&&(e.statusCode=StatusCodes.INTERNAL_SERVER_ERROR);};var T="An error occurred",W=(e,o,t)=>{if(y(t,e),R(t,e),e instanceof h.JapiError||h.JapiError.isLikeJapiError(e)){let r=new h.ErrorSerializer;c(t,r.serialize(e));}else if(e instanceof HttpError){let{message:r,statusCode:n,title:a}=e;c(t,{errors:[{code:n,title:a||getReasonPhrase(n)||T,detail:r}]});}else {let{message:r}=e;c(t,{errors:[{code:"500",title:getReasonPhrase(t.statusCode)||T,detail:r}]});}},A=W;var C="https://tools.ietf.org/html/rfc2616#section-10",I="An error occurred",X=(e,o,t)=>{let{message:r,stack:n}=e;if(e instanceof HttpError){let{expose:a,statusCode:s,title:i,type:d}=e;t.statusCode=s,R(t,e),c(t,{type:d||C,title:i||getReasonPhrase(s)||I,details:r,...a?{trace:n}:{}});}else y(t,e),c(t,{type:C,title:getReasonPhrase(t.statusCode)||I,details:r,...e.expose?{trace:n}:{}});},O=X;var H=(e,o)=>async(t,r,n)=>{let a=r.headers.accept,s=O;a==="application/vnd.api+json"&&(s=A);for(let{handler:i,regex:d}of e)if(d.test(a)){s=i;break}t.expose=o,s(t,r,n);},S=async(e,o,t)=>{let r=[...new Set(t.map(n=>n.method))].join(", ");throw o.setHeader("Allow",r),o.statusCode=405,P(405,`No route with [${e.method}] method found.`)};var q={alpn:"ALPN","c-pep":"C-PEP","c-pep-info":"C-PEP-Info","caldav-timezones":"CalDAV-Timezones","content-id":"Content-ID","content-md5":"Content-MD5",dasl:"DASL",dav:"DAV",dnt:"DNT",etag:"ETag",getprofile:"GetProfile","http2-settings":"HTTP2-Settings","last-event-id":"Last-Event-ID","mime-version":"MIME-Version","optional-www-authenticate":"Optional-WWW-Authenticate","sec-webSocket-key":"Sec-WebSocket-Key","sec-webSocket-protocol":"Sec-WebSocket-Protocol","sec-webSocket-version":"Sec-WebSocket-Version","sec-websocket-accept":"Sec-WebSocket-Accept","sec-websocket-extensions":"Sec-WebSocket-Extensions",slug:"SLUG",tcn:"TCN",te:"TE",ttl:"TTL","www-authenticate":"WWW-Authenticate","x-att-deviceid":"X-ATT-DeviceId","x-dnsprefetch-control":"X-DNSPrefetch-Control","x-uidh":"X-UIDH"},Z=(e,o)=>{let t=e.toLowerCase();return o?q[t]?q[t]:t.split("-").map(r=>r[0]?.toUpperCase()+r.slice(1)).join("-"):t},B={canonical:!1,normalizeHeaderKey:Z},G=e=>{let o={...B,...e};return async(t,r,n)=>{let a={},s={};return Object.keys(t.headers).forEach(i=>{a[i]=t.headers[i];let d=o.normalizeHeaderKey(i,o.canonical);d&&(s[d]=t.headers[i]);}),t.headers=s,t.rawHeaders=a,n()}},E=G;var _=e=>{if(typeof e!="string")return !1;try{let o=JSON.parse(e),t=Object.prototype.toString.call(o);return t==="[object Object]"||t==="[object Array]"}catch{return !1}},w=_;var Q=e=>toXML(e,{header:!0,indent:" "}),g=Q;var x="Content-Type",ee=(e,o,t,r,n)=>{if(typeof t.getHeader(x)=="string")return r;let i=[...Y(o).types(),n.defaultContentType],d=r,b$1=!1;return i.forEach(m=>{e.forEach(({regex:k,serializer:L})=>{k.test(m)&&(t.setHeader(x,m),d=L(d),b$1=!0);}),b$1||(/yaml|yml/.test(m)?(t.setHeader(x,m),d=b(w(r)?JSON.parse(r):r)):m.includes("xml")&&(t.setHeader(x,m),d=g({[a(`${o.url?.replace("/api/","")}`.trim())]:w(r)?JSON.parse(r):r})));}),d},f=ee;var re=te("api-platform:connect:serializers-middleware"),oe=(e=[],o="application/json; charset=utf-8")=>async(t,r,n)=>{if(typeof r.send=="function"){let a=r.send;r.send=s=>{r.send=a,s=f(e,t,r,s,{defaultContentType:o}),r.send(s);};}else if(typeof r.json=="function")re("response.json() is not supported by @visulima/api-platform serializer. Use response.send() or response.end() instead.");else {let a=r.end;r.end=(s,...i)=>(r.end=a,s=f(e,t,r,s,{defaultContentType:o}),r.end(s,...i));}return n()},N=oe;var ne=(e={})=>new NodeRouter({onError:H(e.errorHandlers??[],e.showTrace??!1),onNoMatch:S}).use(E(e.middlewares?.["http-header-normalizer"]??{})).use(N(e.middlewares?.serializers?.serializers??[],e.middlewares?.serializers?.defaultContentType??"application/json; charset=utf-8")),ae=ne;var pe=e=>expressWrapper(de(e)),le=pe;var ce=e=>e.ip??e.headers["x-forwarded-for"]??e.headers["x-real-ip"]??e.socket.remoteAddress,me=(e,o)=>async(t,r,n)=>{let a=ce(t);if(a===void 0)throw P(400,"Missing IP");try{let s=await e.consume(a),i={"Retry-After":Math.round(s.msBeforeNext/1e3)||1,"X-RateLimit-Remaining":s.remainingPoints,"X-RateLimit-Reset":new Date(Date.now()+s.msBeforeNext).toISOString(),...o};Object.keys(i).forEach(d=>{r.setHeader(d,i[d]);}),await n();}catch{throw P(429,"Too Many Requests")}},fe=me;
17
17
 
18
18
  export { le as corsMiddleware, ae as createNodeRouter, E as httpHeaderNormalizerMiddleware, H as onError, S as onNoMatch, fe as rateLimiterMiddleware, f as serialize, N as serializersMiddleware, g as xmlTransformer };
19
- //# sourceMappingURL=out.js.map
19
+ //# sourceMappingURL=index-server.mjs.map
20
20
  //# sourceMappingURL=index-server.mjs.map