@verdaccio/middleware 9.0.0-next-9.4 → 9.0.0-next-9.5
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/build/index.d.ts +1 -0
- package/build/index.js +2 -0
- package/build/index.mjs +2 -1
- package/build/middlewares/body-parser.d.ts +8 -0
- package/build/middlewares/body-parser.js +31 -0
- package/build/middlewares/body-parser.js.map +1 -0
- package/build/middlewares/body-parser.mjs +28 -0
- package/build/middlewares/body-parser.mjs.map +1 -0
- package/package.json +7 -7
package/build/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { antiLoop } from './middlewares/antiLoop';
|
|
|
10
10
|
export { final } from './middlewares/final';
|
|
11
11
|
export { allow } from './middlewares/allow';
|
|
12
12
|
export { rateLimit } from './middlewares/rate-limit';
|
|
13
|
+
export { registerBodyParser } from './middlewares/body-parser';
|
|
13
14
|
export { userAgent } from './middlewares/user-agent';
|
|
14
15
|
export { webMiddleware, renderWebMiddleware, setSecurityWebHeaders } from './middlewares/web';
|
|
15
16
|
export { errorReportingMiddleware, handleError } from './middlewares/error';
|
package/build/index.js
CHANGED
|
@@ -13,6 +13,7 @@ const require_antiLoop = require("./middlewares/antiLoop.js");
|
|
|
13
13
|
const require_final = require("./middlewares/final.js");
|
|
14
14
|
const require_allow = require("./middlewares/allow.js");
|
|
15
15
|
const require_rate_limit = require("./middlewares/rate-limit.js");
|
|
16
|
+
const require_body_parser = require("./middlewares/body-parser.js");
|
|
16
17
|
const require_user_agent = require("./middlewares/user-agent.js");
|
|
17
18
|
const require_security = require("./middlewares/web/security.js");
|
|
18
19
|
const require_web_urls = require("./middlewares/web/web-urls.js");
|
|
@@ -52,6 +53,7 @@ exports.makeURLrelative = require_make_url_relative.makeURLrelative;
|
|
|
52
53
|
exports.match = require_match.match;
|
|
53
54
|
exports.media = require_media.media;
|
|
54
55
|
exports.rateLimit = require_rate_limit.rateLimit;
|
|
56
|
+
exports.registerBodyParser = require_body_parser.registerBodyParser;
|
|
55
57
|
exports.renderWebMiddleware = require_render_web.renderWebMiddleware;
|
|
56
58
|
exports.setSecurityWebHeaders = require_security.setSecurityWebHeaders;
|
|
57
59
|
exports.userAgent = require_user_agent.userAgent;
|
package/build/index.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { antiLoop } from "./middlewares/antiLoop.mjs";
|
|
|
9
9
|
import { final } from "./middlewares/final.mjs";
|
|
10
10
|
import { allow } from "./middlewares/allow.mjs";
|
|
11
11
|
import { rateLimit } from "./middlewares/rate-limit.mjs";
|
|
12
|
+
import { registerBodyParser } from "./middlewares/body-parser.mjs";
|
|
12
13
|
import { userAgent } from "./middlewares/user-agent.mjs";
|
|
13
14
|
import { setSecurityWebHeaders } from "./middlewares/web/security.mjs";
|
|
14
15
|
import { WebUrls, WebUrlsNamespace } from "./middlewares/web/web-urls.mjs";
|
|
@@ -19,4 +20,4 @@ import { errorReportingMiddleware, handleError } from "./middlewares/error.mjs";
|
|
|
19
20
|
import { getRequestOptions } from "./middlewares/request-options.mjs";
|
|
20
21
|
import { LOG_STATUS_MESSAGE, LOG_VERDACCIO_BYTES, LOG_VERDACCIO_ERROR, log } from "./middlewares/log.mjs";
|
|
21
22
|
import { DIST_TAGS_API_ENDPOINTS, LOGIN_API_ENDPOINTS, PACKAGE_API_ENDPOINTS, PING_API_ENDPOINTS, PROFILE_API_ENDPOINTS, PUBLISH_API_ENDPOINTS, SEARCH_API_ENDPOINTS, STARS_API_ENDPOINTS, TOKEN_API_ENDPOINTS, USER_API_ENDPOINTS } from "./middlewares/api_urls.mjs";
|
|
22
|
-
export { DIST_TAGS_API_ENDPOINTS, LOGIN_API_ENDPOINTS, LOG_STATUS_MESSAGE, LOG_VERDACCIO_BYTES, LOG_VERDACCIO_ERROR, PACKAGE_API_ENDPOINTS, PING_API_ENDPOINTS, PROFILE_API_ENDPOINTS, PUBLISH_API_ENDPOINTS, SEARCH_API_ENDPOINTS, STARS_API_ENDPOINTS, TOKEN_API_ENDPOINTS, USER_API_ENDPOINTS, WebUrls, WebUrlsNamespace, allow, antiLoop, dotfiles, encodeScopePackage, errorReportingMiddleware, expectJson, final, getRequestOptions, handleError, log, makeURLrelative, match, media, rateLimit, renderWebMiddleware, setSecurityWebHeaders, userAgent, validateName, validatePackage, web_middleware_default as webMiddleware };
|
|
23
|
+
export { DIST_TAGS_API_ENDPOINTS, LOGIN_API_ENDPOINTS, LOG_STATUS_MESSAGE, LOG_VERDACCIO_BYTES, LOG_VERDACCIO_ERROR, PACKAGE_API_ENDPOINTS, PING_API_ENDPOINTS, PROFILE_API_ENDPOINTS, PUBLISH_API_ENDPOINTS, SEARCH_API_ENDPOINTS, STARS_API_ENDPOINTS, TOKEN_API_ENDPOINTS, USER_API_ENDPOINTS, WebUrls, WebUrlsNamespace, allow, antiLoop, dotfiles, encodeScopePackage, errorReportingMiddleware, expectJson, final, getRequestOptions, handleError, log, makeURLrelative, match, media, rateLimit, registerBodyParser, renderWebMiddleware, setSecurityWebHeaders, userAgent, validateName, validatePackage, web_middleware_default as webMiddleware };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Application, Router } from 'express';
|
|
2
|
+
import { Config } from '@verdaccio/types';
|
|
3
|
+
/**
|
|
4
|
+
* Register JSON body parser on a router if not already registered
|
|
5
|
+
* @param app Express router instance
|
|
6
|
+
* @param config Verdaccio config
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerBodyParser(app: Router | Application, config: Config): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let debug = require("debug");
|
|
3
|
+
debug = require_runtime.__toESM(debug);
|
|
4
|
+
let express = require("express");
|
|
5
|
+
express = require_runtime.__toESM(express);
|
|
6
|
+
//#region src/middlewares/body-parser.ts
|
|
7
|
+
var debug$1 = (0, debug.default)("verdaccio:middleware:body-parser");
|
|
8
|
+
/**
|
|
9
|
+
* Check if a body parser is already registered on the router
|
|
10
|
+
*/
|
|
11
|
+
function hasBodyParser(app) {
|
|
12
|
+
return (app.stack || app._router?.stack || []).some((middleware) => {
|
|
13
|
+
return middleware.handle?.name === "jsonParser" || middleware.name === "jsonParser";
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Register JSON body parser on a router if not already registered
|
|
18
|
+
* @param app Express router instance
|
|
19
|
+
* @param config Verdaccio config
|
|
20
|
+
*/
|
|
21
|
+
function registerBodyParser(app, config) {
|
|
22
|
+
if (hasBodyParser(app)) debug$1("json parser already registered");
|
|
23
|
+
else app.use(express.default.json({
|
|
24
|
+
strict: false,
|
|
25
|
+
limit: config.max_body_size || "10mb"
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.registerBodyParser = registerBodyParser;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=body-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body-parser.js","names":[],"sources":["../../src/middlewares/body-parser.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Application, Router } from 'express';\nimport express from 'express';\n\nimport type { Config } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:middleware:body-parser');\n\n/**\n * Check if a body parser is already registered on the router\n */\nfunction hasBodyParser(app: Router | Application): boolean {\n // @ts-ignore - Express internals: app.stack is not part of the public API\n const stack = (app as any).stack || (app as any)._router?.stack || [];\n return stack.some((middleware: any) => {\n return middleware.handle?.name === 'jsonParser' || middleware.name === 'jsonParser';\n });\n}\n\n/**\n * Register JSON body parser on a router if not already registered\n * @param app Express router instance\n * @param config Verdaccio config\n */\nexport function registerBodyParser(app: Router | Application, config: Config): void {\n // middleware might have registered a json parser already\n if (hasBodyParser(app)) {\n debug('json parser already registered');\n } else {\n app.use(\n express.json({\n strict: false,\n limit: config.max_body_size || '10mb',\n })\n );\n }\n}\n"],"mappings":";;;;;;AAMA,IAAM,WAAA,GAAA,MAAA,SAAmB,mCAAmC;;;;AAK5D,SAAS,cAAc,KAAoC;AAGzD,SADe,IAAY,SAAU,IAAY,SAAS,SAAS,EAAE,EACxD,MAAM,eAAoB;AACrC,SAAO,WAAW,QAAQ,SAAS,gBAAgB,WAAW,SAAS;GACvE;;;;;;;AAQJ,SAAgB,mBAAmB,KAA2B,QAAsB;AAElF,KAAI,cAAc,IAAI,CACpB,SAAM,iCAAiC;KAEvC,KAAI,IACF,QAAA,QAAQ,KAAK;EACX,QAAQ;EACR,OAAO,OAAO,iBAAiB;EAChC,CAAC,CACH"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import buildDebug from "debug";
|
|
2
|
+
import express from "express";
|
|
3
|
+
//#region src/middlewares/body-parser.ts
|
|
4
|
+
var debug = buildDebug("verdaccio:middleware:body-parser");
|
|
5
|
+
/**
|
|
6
|
+
* Check if a body parser is already registered on the router
|
|
7
|
+
*/
|
|
8
|
+
function hasBodyParser(app) {
|
|
9
|
+
return (app.stack || app._router?.stack || []).some((middleware) => {
|
|
10
|
+
return middleware.handle?.name === "jsonParser" || middleware.name === "jsonParser";
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Register JSON body parser on a router if not already registered
|
|
15
|
+
* @param app Express router instance
|
|
16
|
+
* @param config Verdaccio config
|
|
17
|
+
*/
|
|
18
|
+
function registerBodyParser(app, config) {
|
|
19
|
+
if (hasBodyParser(app)) debug("json parser already registered");
|
|
20
|
+
else app.use(express.json({
|
|
21
|
+
strict: false,
|
|
22
|
+
limit: config.max_body_size || "10mb"
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { registerBodyParser };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=body-parser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body-parser.mjs","names":[],"sources":["../../src/middlewares/body-parser.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Application, Router } from 'express';\nimport express from 'express';\n\nimport type { Config } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:middleware:body-parser');\n\n/**\n * Check if a body parser is already registered on the router\n */\nfunction hasBodyParser(app: Router | Application): boolean {\n // @ts-ignore - Express internals: app.stack is not part of the public API\n const stack = (app as any).stack || (app as any)._router?.stack || [];\n return stack.some((middleware: any) => {\n return middleware.handle?.name === 'jsonParser' || middleware.name === 'jsonParser';\n });\n}\n\n/**\n * Register JSON body parser on a router if not already registered\n * @param app Express router instance\n * @param config Verdaccio config\n */\nexport function registerBodyParser(app: Router | Application, config: Config): void {\n // middleware might have registered a json parser already\n if (hasBodyParser(app)) {\n debug('json parser already registered');\n } else {\n app.use(\n express.json({\n strict: false,\n limit: config.max_body_size || '10mb',\n })\n );\n }\n}\n"],"mappings":";;;AAMA,IAAM,QAAQ,WAAW,mCAAmC;;;;AAK5D,SAAS,cAAc,KAAoC;AAGzD,SADe,IAAY,SAAU,IAAY,SAAS,SAAS,EAAE,EACxD,MAAM,eAAoB;AACrC,SAAO,WAAW,QAAQ,SAAS,gBAAgB,WAAW,SAAS;GACvE;;;;;;;AAQJ,SAAgB,mBAAmB,KAA2B,QAAsB;AAElF,KAAI,cAAc,IAAI,CACpB,OAAM,iCAAiC;KAEvC,KAAI,IACF,QAAQ,KAAK;EACX,QAAQ;EACR,OAAO,OAAO,iBAAiB;EAChC,CAAC,CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/middleware",
|
|
3
|
-
"version": "9.0.0-next-9.
|
|
3
|
+
"version": "9.0.0-next-9.5",
|
|
4
4
|
"description": "Verdaccio Express Middleware",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"node": ">=24"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@verdaccio/config": "9.0.0-next-9.
|
|
37
|
-
"@verdaccio/core": "9.0.0-next-9.
|
|
38
|
-
"@verdaccio/url": "14.0.0-next-9.
|
|
36
|
+
"@verdaccio/config": "9.0.0-next-9.5",
|
|
37
|
+
"@verdaccio/core": "9.0.0-next-9.5",
|
|
38
|
+
"@verdaccio/url": "14.0.0-next-9.5",
|
|
39
39
|
"debug": "4.4.3",
|
|
40
40
|
"express": "5.2.1",
|
|
41
41
|
"express-rate-limit": "8.2.1",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"url": "https://opencollective.com/verdaccio"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@verdaccio/logger": "9.0.0-next-9.
|
|
51
|
-
"@verdaccio/types": "14.0.0-next-9.
|
|
50
|
+
"@verdaccio/logger": "9.0.0-next-9.5",
|
|
51
|
+
"@verdaccio/types": "14.0.0-next-9.2",
|
|
52
52
|
"http-errors": "2.0.1",
|
|
53
53
|
"supertest": "7.1.4",
|
|
54
54
|
"jsdom": "28.1.0",
|
|
55
|
-
"vitest": "
|
|
55
|
+
"vitest": "4.1.0"
|
|
56
56
|
},
|
|
57
57
|
"module": "./build/index.mjs",
|
|
58
58
|
"exports": {
|