@verdaccio/server 7.0.0-next.4 → 7.0.0-next.6
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/CHANGELOG.md +39 -0
- package/LICENSE +1 -1
- package/build/server.js +26 -16
- package/build/server.js.map +1 -1
- package/package.json +14 -14
- package/src/server.ts +33 -24
- package/test/_helper.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @verdaccio/server
|
|
2
2
|
|
|
3
|
+
## 7.0.0-next.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [e14b064]
|
|
8
|
+
- Updated dependencies [4d96324]
|
|
9
|
+
- @verdaccio/store@7.0.0-next.6
|
|
10
|
+
- @verdaccio/config@7.0.0-next.6
|
|
11
|
+
- @verdaccio/api@7.0.0-next.6
|
|
12
|
+
- @verdaccio/web@7.0.0-next.6
|
|
13
|
+
- @verdaccio/auth@7.0.0-next.6
|
|
14
|
+
- @verdaccio/loaders@7.0.0-next.6
|
|
15
|
+
- @verdaccio/middleware@7.0.0-next.6
|
|
16
|
+
- verdaccio-audit@12.0.0-next.6
|
|
17
|
+
- @verdaccio/core@7.0.0-next.6
|
|
18
|
+
- @verdaccio/utils@7.0.0-next.6
|
|
19
|
+
- @verdaccio/logger@7.0.0-next.6
|
|
20
|
+
|
|
21
|
+
## 7.0.0-next.5
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- f047cc8: refactor: auth with legacy sign support
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [f047cc8]
|
|
30
|
+
- @verdaccio/middleware@7.0.0-next.5
|
|
31
|
+
- @verdaccio/core@7.0.0-next.5
|
|
32
|
+
- @verdaccio/config@7.0.0-next.5
|
|
33
|
+
- @verdaccio/auth@7.0.0-next.5
|
|
34
|
+
- @verdaccio/api@7.0.0-next.5
|
|
35
|
+
- @verdaccio/store@7.0.0-next.5
|
|
36
|
+
- @verdaccio/web@7.0.0-next.5
|
|
37
|
+
- @verdaccio/loaders@7.0.0-next.5
|
|
38
|
+
- @verdaccio/logger@7.0.0-next.5
|
|
39
|
+
- verdaccio-audit@12.0.0-next.5
|
|
40
|
+
- @verdaccio/utils@7.0.0-next.5
|
|
41
|
+
|
|
3
42
|
## 7.0.0-next.4
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/LICENSE
CHANGED
package/build/server.js
CHANGED
|
@@ -97,22 +97,32 @@ const defineAPI = async function (config, storage) {
|
|
|
97
97
|
app.get('/*', function (req, res, next) {
|
|
98
98
|
next(_core.errorUtils.getNotFound('resource not found'));
|
|
99
99
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
app.use((0, _middleware.handleError)(_logger.logger));
|
|
103
|
+
|
|
104
|
+
// app.use(function (
|
|
105
|
+
// err: HttpError,
|
|
106
|
+
// req: $RequestExtend,
|
|
107
|
+
// res: $ResponseExtend,
|
|
108
|
+
// next: $NextFunctionVer
|
|
109
|
+
// ) {
|
|
110
|
+
// if (_.isError(err)) {
|
|
111
|
+
// if (err.code === 'ECONNABORT' && res.statusCode === HTTP_STATUS.NOT_MODIFIED) {
|
|
112
|
+
// return next();
|
|
113
|
+
// }
|
|
114
|
+
// if (_.isFunction(res.locals.report_error) === false) {
|
|
115
|
+
// // in case of very early error this middleware may not be loaded before error is generated
|
|
116
|
+
// // fixing that
|
|
117
|
+
// errorReportingMiddlewareWrap(req, res, _.noop);
|
|
118
|
+
// }
|
|
119
|
+
// res.locals.report_error(err);
|
|
120
|
+
// } else {
|
|
121
|
+
// // Fall to Middleware.final
|
|
122
|
+
// return next(err);
|
|
123
|
+
// }
|
|
124
|
+
// });
|
|
125
|
+
|
|
116
126
|
app.use(_middleware.final);
|
|
117
127
|
return app;
|
|
118
128
|
};
|
package/build/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["_compression","_interopRequireDefault","require","_cors","_debug","_express","_lodash","_verdaccioAudit","_api","_auth","_config","_core","_loaders","_logger","_middleware","_store","_web","_debug2","obj","__esModule","default","debug","buildDebug","version","defineAPI","config","storage","_config$server","auth","Auth","init","app","express","set","process","env","NODE_ENV","server","trustProxy","use","cors","rateLimit","serverSettings","errorReportingMiddlewareWrap","errorReportingMiddleware","logger","log","userAgent","compression","get","req","res","next","url","hookDebug","configPath","plugins","asyncLoadPlugin","middlewares","plugin","register_middlewares","length","info","push","AuditMiddleware","enabled","strict_ssl","forEach","apiEndpoint","_","_req","locals","app_version","middleware","webMiddleware","errorUtils","getNotFound","API_ERROR","WEB_DISABLED","err","isError","code","statusCode","HTTP_STATUS","NOT_MODIFIED","isFunction","report_error","noop","final","startServer","exports","configHash","AppConfig","Storage","error","msg","Error"],"sources":["../src/server.ts"],"sourcesContent":["import compression from 'compression';\nimport cors from 'cors';\nimport buildDebug from 'debug';\nimport express from 'express';\nimport { HttpError } from 'http-errors';\nimport _ from 'lodash';\nimport AuditMiddleware from 'verdaccio-audit';\n\nimport apiEndpoint from '@verdaccio/api';\nimport { Auth } from '@verdaccio/auth';\nimport { Config as AppConfig } from '@verdaccio/config';\nimport { API_ERROR, HTTP_STATUS, errorUtils, pluginUtils } from '@verdaccio/core';\nimport { asyncLoadPlugin } from '@verdaccio/loaders';\nimport { logger } from '@verdaccio/logger';\nimport { errorReportingMiddleware, final, log, rateLimit, userAgent } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { ConfigYaml } from '@verdaccio/types';\nimport { Config as IConfig } from '@verdaccio/types';\nimport webMiddleware from '@verdaccio/web';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\nimport hookDebug from './debug';\n\nconst debug = buildDebug('verdaccio:server');\nconst { version } = require('../package.json');\n\nconst defineAPI = async function (config: IConfig, storage: Storage): Promise<any> {\n const auth: Auth = new Auth(config);\n await auth.init();\n const app = express();\n // run in production mode by default, just in case\n // it shouldn't make any difference anyway\n app.set('env', process.env.NODE_ENV || 'production');\n if (config.server?.trustProxy) {\n app.set('trust proxy', config.server.trustProxy);\n }\n app.use(cors());\n app.use(rateLimit(config.serverSettings.rateLimit));\n\n const errorReportingMiddlewareWrap = errorReportingMiddleware(logger);\n\n // Router setup\n app.use(log(logger));\n app.use(errorReportingMiddlewareWrap);\n app.use(userAgent(config));\n app.use(compression());\n\n app.get(\n '/favicon.ico',\n function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n req.url = '/-/static/favicon.ico';\n next();\n }\n );\n\n // Hook for tests only\n if (config._debug) {\n hookDebug(app, config.configPath);\n }\n\n const plugins: pluginUtils.ExpressMiddleware<IConfig, {}, Auth>[] = await asyncLoadPlugin(\n config.middlewares,\n {\n config,\n logger,\n },\n function (plugin) {\n return typeof plugin.register_middlewares !== 'undefined';\n }\n );\n\n if (plugins.length === 0) {\n logger.info('none middleware plugins has been defined, adding audit middleware by default');\n // @ts-ignore\n plugins.push(new AuditMiddleware({ enabled: true, strict_ssl: true }, { config, logger }));\n }\n\n plugins.forEach((plugin: pluginUtils.ExpressMiddleware<IConfig, {}, Auth>) => {\n plugin.register_middlewares(app, auth, storage);\n });\n\n // For npm request\n // @ts-ignore\n app.use(apiEndpoint(config, auth, storage));\n\n // For WebUI & WebUI API\n if (_.get(config, 'web.enable', true)) {\n app.use((_req, res, next) => {\n res.locals.app_version = version ?? '';\n next();\n });\n const middleware = await webMiddleware(config, auth, storage);\n app.use(middleware);\n } else {\n app.get('/', function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {\n next(errorUtils.getNotFound(API_ERROR.WEB_DISABLED));\n });\n }\n\n // Catch 404\n app.get('/*', function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {\n next(errorUtils.getNotFound('resource not found'));\n });\n\n app.use(function (\n err: HttpError,\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ) {\n if (_.isError(err)) {\n if (err.code === 'ECONNABORT' && res.statusCode === HTTP_STATUS.NOT_MODIFIED) {\n return next();\n }\n if (_.isFunction(res.locals.report_error) === false) {\n // in case of very early error this middleware may not be loaded before error is generated\n // fixing that\n errorReportingMiddlewareWrap(req, res, _.noop);\n }\n res.locals.report_error(err);\n } else {\n // Fall to Middleware.final\n return next(err);\n }\n });\n\n app.use(final);\n\n return app;\n};\n\nexport default (async function startServer(configHash: ConfigYaml): Promise<any> {\n debug('start server');\n const config: IConfig = new AppConfig({ ...configHash } as any);\n // register middleware plugins\n debug('loaded filter plugin');\n // @ts-ignore\n const storage: Storage = new Storage(config);\n try {\n // waits until init calls have been initialized\n debug('storage init start');\n await storage.init(config);\n debug('storage init end');\n } catch (err: any) {\n logger.error({ error: err.msg }, 'storage has failed: @{error}');\n throw new Error(err);\n }\n return await defineAPI(config, storage);\n});\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,IAAAM,IAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;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K,KAAK,EAAE;QACnD;QACA;QACA3C,4BAA4B,CAACO,GAAG,EAAEC,GAAG,EAAEkB,eAAC,CAACkB,IAAI,CAAC;MAChD;MACApC,GAAG,CAACoB,MAAM,CAACe,YAAY,CAACP,GAAG,CAAC;IAC9B,CAAC,MAAM;MACL;MACA,OAAO3B,IAAI,CAAC2B,GAAG,CAAC;IAClB;EACF,CAAC,CAAC;EAEFhD,GAAG,CAACQ,GAAG,CAACiD,iBAAK,CAAC;EAEd,OAAOzD,GAAG;AACZ,CAAC;AAAC,IAE6B0D,WAAW,GAAAC,OAAA,CAAAtE,OAAA,GAA1B,eAAeqE,WAAWA,CAACE,UAAsB,EAAgB;EAC/EtE,KAAK,CAAC,cAAc,CAAC;EACrB,MAAMI,MAAe,GAAG,IAAImE,cAAS,CAAC;IAAE,GAAGD;EAAW,CAAQ,CAAC;EAC/D;EACAtE,KAAK,CAAC,sBAAsB,CAAC;EAC7B;EACA,MAAMK,OAAgB,GAAG,IAAImE,cAAO,CAACpE,MAAM,CAAC;EAC5C,IAAI;IACF;IACAJ,KAAK,CAAC,oBAAoB,CAAC;IAC3B,MAAMK,OAAO,CAACI,IAAI,CAACL,MAAM,CAAC;IAC1BJ,KAAK,CAAC,kBAAkB,CAAC;EAC3B,CAAC,CAAC,OAAO0D,GAAQ,EAAE;IACjBlC,cAAM,CAACiD,KAAK,CAAC;MAAEA,KAAK,EAAEf,GAAG,CAACgB;IAAI,CAAC,EAAE,8BAA8B,CAAC;IAChE,MAAM,IAAIC,KAAK,CAACjB,GAAG,CAAC;EACtB;EACA,OAAO,MAAMvD,SAAS,CAACC,MAAM,EAAEC,OAAO,CAAC;AACzC,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.js","names":["_compression","_interopRequireDefault","require","_cors","_debug","_express","_lodash","_verdaccioAudit","_api","_auth","_config","_core","_loaders","_logger","_middleware","_store","_web","_debug2","obj","__esModule","default","debug","buildDebug","version","defineAPI","config","storage","_config$server","auth","Auth","init","app","express","set","process","env","NODE_ENV","server","trustProxy","use","cors","rateLimit","serverSettings","errorReportingMiddlewareWrap","errorReportingMiddleware","logger","log","userAgent","compression","get","req","res","next","url","hookDebug","configPath","plugins","asyncLoadPlugin","middlewares","plugin","register_middlewares","length","info","push","AuditMiddleware","enabled","strict_ssl","forEach","apiEndpoint","_","_req","locals","app_version","middleware","webMiddleware","errorUtils","getNotFound","API_ERROR","WEB_DISABLED","handleError","final","startServer","exports","configHash","AppConfig","Storage","err","error","msg","Error"],"sources":["../src/server.ts"],"sourcesContent":["import compression from 'compression';\nimport cors from 'cors';\nimport buildDebug from 'debug';\nimport express from 'express';\nimport _ from 'lodash';\nimport AuditMiddleware from 'verdaccio-audit';\n\nimport apiEndpoint from '@verdaccio/api';\nimport { Auth } from '@verdaccio/auth';\nimport { Config as AppConfig } from '@verdaccio/config';\nimport { API_ERROR, errorUtils, pluginUtils } from '@verdaccio/core';\nimport { asyncLoadPlugin } from '@verdaccio/loaders';\nimport { logger } from '@verdaccio/logger';\nimport {\n errorReportingMiddleware,\n final,\n handleError,\n log,\n rateLimit,\n userAgent,\n} from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { ConfigYaml } from '@verdaccio/types';\nimport { Config as IConfig } from '@verdaccio/types';\nimport webMiddleware from '@verdaccio/web';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\nimport hookDebug from './debug';\n\nconst debug = buildDebug('verdaccio:server');\nconst { version } = require('../package.json');\n\nconst defineAPI = async function (config: IConfig, storage: Storage): Promise<any> {\n const auth: Auth = new Auth(config);\n await auth.init();\n const app = express();\n // run in production mode by default, just in case\n // it shouldn't make any difference anyway\n app.set('env', process.env.NODE_ENV || 'production');\n if (config.server?.trustProxy) {\n app.set('trust proxy', config.server.trustProxy);\n }\n app.use(cors());\n app.use(rateLimit(config.serverSettings.rateLimit));\n\n const errorReportingMiddlewareWrap = errorReportingMiddleware(logger);\n\n // Router setup\n app.use(log(logger));\n app.use(errorReportingMiddlewareWrap);\n app.use(userAgent(config));\n app.use(compression());\n\n app.get(\n '/favicon.ico',\n function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n req.url = '/-/static/favicon.ico';\n next();\n }\n );\n\n // Hook for tests only\n if (config._debug) {\n hookDebug(app, config.configPath);\n }\n\n const plugins: pluginUtils.ExpressMiddleware<IConfig, {}, Auth>[] = await asyncLoadPlugin(\n config.middlewares,\n {\n config,\n logger,\n },\n function (plugin) {\n return typeof plugin.register_middlewares !== 'undefined';\n }\n );\n\n if (plugins.length === 0) {\n logger.info('none middleware plugins has been defined, adding audit middleware by default');\n // @ts-ignore\n plugins.push(new AuditMiddleware({ enabled: true, strict_ssl: true }, { config, logger }));\n }\n\n plugins.forEach((plugin: pluginUtils.ExpressMiddleware<IConfig, {}, Auth>) => {\n plugin.register_middlewares(app, auth, storage);\n });\n\n // For npm request\n // @ts-ignore\n app.use(apiEndpoint(config, auth, storage));\n\n // For WebUI & WebUI API\n if (_.get(config, 'web.enable', true)) {\n app.use((_req, res, next) => {\n res.locals.app_version = version ?? '';\n next();\n });\n const middleware = await webMiddleware(config, auth, storage);\n app.use(middleware);\n } else {\n app.get('/', function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {\n next(errorUtils.getNotFound(API_ERROR.WEB_DISABLED));\n });\n }\n\n // Catch 404\n app.get('/*', function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {\n next(errorUtils.getNotFound('resource not found'));\n });\n\n // @ts-ignore\n app.use(handleError(logger));\n\n // app.use(function (\n // err: HttpError,\n // req: $RequestExtend,\n // res: $ResponseExtend,\n // next: $NextFunctionVer\n // ) {\n // if (_.isError(err)) {\n // if (err.code === 'ECONNABORT' && res.statusCode === HTTP_STATUS.NOT_MODIFIED) {\n // return next();\n // }\n // if (_.isFunction(res.locals.report_error) === false) {\n // // in case of very early error this middleware may not be loaded before error is generated\n // // fixing that\n // errorReportingMiddlewareWrap(req, res, _.noop);\n // }\n // res.locals.report_error(err);\n // } else {\n // // Fall to Middleware.final\n // return next(err);\n // }\n // });\n\n app.use(final);\n\n return app;\n};\n\nexport default (async function startServer(configHash: ConfigYaml): Promise<any> {\n debug('start server');\n const config: IConfig = new AppConfig({ ...configHash } as any);\n // register middleware plugins\n debug('loaded filter plugin');\n // @ts-ignore\n const storage: Storage = new Storage(config);\n try {\n // waits until init calls have been initialized\n debug('storage init start');\n await storage.init(config);\n debug('storage init end');\n } catch (err: any) {\n logger.error({ error: err.msg }, 'storage has failed: @{error}');\n throw new Error(err);\n }\n return await defineAPI(config, storage);\n});\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,IAAAM,IAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AAQA,IAAAa,MAAA,GAAAb,OAAA;AAGA,IAAAc,IAAA,GAAAf,sBAAA,CAAAC,OAAA;AAGA,IAAAe,OAAA,GAAAhB,sBAAA,CAAAC,OAAA;AAAgC,SAAAD,uBAAAiB,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,kBAAkB,CAAC;AAC5C,MAAM;EAAEC;AAAQ,CAAC,GAA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CAAC0C,KAAK,CAAC;MAAEA,KAAK,EAAED,GAAG,CAACE;IAAI,CAAC,EAAE,8BAA8B,CAAC;IAChE,MAAM,IAAIC,KAAK,CAACH,GAAG,CAAC;EACtB;EACA,OAAO,MAAM9D,SAAS,CAACC,MAAM,EAAEC,OAAO,CAAC;AACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/server",
|
|
3
|
-
"version": "7.0.0-next.
|
|
3
|
+
"version": "7.0.0-next.6",
|
|
4
4
|
"description": "server logic",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"node": ">=18"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@verdaccio/api": "7.0.0-next.
|
|
33
|
-
"@verdaccio/auth": "7.0.0-next.
|
|
34
|
-
"@verdaccio/core": "7.0.0-next.
|
|
35
|
-
"@verdaccio/config": "7.0.0-next.
|
|
36
|
-
"@verdaccio/loaders": "7.0.0-next.
|
|
37
|
-
"@verdaccio/logger": "7.0.0-next.
|
|
38
|
-
"@verdaccio/middleware": "7.0.0-next.
|
|
39
|
-
"@verdaccio/store": "7.0.0-next.
|
|
40
|
-
"@verdaccio/utils": "7.0.0-next.
|
|
41
|
-
"@verdaccio/web": "7.0.0-next.
|
|
42
|
-
"verdaccio-audit": "12.0.0-next.
|
|
32
|
+
"@verdaccio/api": "7.0.0-next.6",
|
|
33
|
+
"@verdaccio/auth": "7.0.0-next.6",
|
|
34
|
+
"@verdaccio/core": "7.0.0-next.6",
|
|
35
|
+
"@verdaccio/config": "7.0.0-next.6",
|
|
36
|
+
"@verdaccio/loaders": "7.0.0-next.6",
|
|
37
|
+
"@verdaccio/logger": "7.0.0-next.6",
|
|
38
|
+
"@verdaccio/middleware": "7.0.0-next.6",
|
|
39
|
+
"@verdaccio/store": "7.0.0-next.6",
|
|
40
|
+
"@verdaccio/utils": "7.0.0-next.6",
|
|
41
|
+
"@verdaccio/web": "7.0.0-next.6",
|
|
42
|
+
"verdaccio-audit": "12.0.0-next.6",
|
|
43
43
|
"compression": "1.7.4",
|
|
44
44
|
"cors": "2.8.5",
|
|
45
45
|
"debug": "4.3.4",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"lodash": "4.17.21"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@verdaccio/proxy": "7.0.0-next.
|
|
51
|
-
"@verdaccio/test-helper": "3.0.0-next.
|
|
50
|
+
"@verdaccio/proxy": "7.0.0-next.6",
|
|
51
|
+
"@verdaccio/test-helper": "3.0.0-next.1",
|
|
52
52
|
"http-errors": "2.0.0"
|
|
53
53
|
},
|
|
54
54
|
"funding": {
|
package/src/server.ts
CHANGED
|
@@ -2,17 +2,23 @@ import compression from 'compression';
|
|
|
2
2
|
import cors from 'cors';
|
|
3
3
|
import buildDebug from 'debug';
|
|
4
4
|
import express from 'express';
|
|
5
|
-
import { HttpError } from 'http-errors';
|
|
6
5
|
import _ from 'lodash';
|
|
7
6
|
import AuditMiddleware from 'verdaccio-audit';
|
|
8
7
|
|
|
9
8
|
import apiEndpoint from '@verdaccio/api';
|
|
10
9
|
import { Auth } from '@verdaccio/auth';
|
|
11
10
|
import { Config as AppConfig } from '@verdaccio/config';
|
|
12
|
-
import { API_ERROR,
|
|
11
|
+
import { API_ERROR, errorUtils, pluginUtils } from '@verdaccio/core';
|
|
13
12
|
import { asyncLoadPlugin } from '@verdaccio/loaders';
|
|
14
13
|
import { logger } from '@verdaccio/logger';
|
|
15
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
errorReportingMiddleware,
|
|
16
|
+
final,
|
|
17
|
+
handleError,
|
|
18
|
+
log,
|
|
19
|
+
rateLimit,
|
|
20
|
+
userAgent,
|
|
21
|
+
} from '@verdaccio/middleware';
|
|
16
22
|
import { Storage } from '@verdaccio/store';
|
|
17
23
|
import { ConfigYaml } from '@verdaccio/types';
|
|
18
24
|
import { Config as IConfig } from '@verdaccio/types';
|
|
@@ -102,27 +108,30 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise<an
|
|
|
102
108
|
next(errorUtils.getNotFound('resource not found'));
|
|
103
109
|
});
|
|
104
110
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
app.use(handleError(logger));
|
|
113
|
+
|
|
114
|
+
// app.use(function (
|
|
115
|
+
// err: HttpError,
|
|
116
|
+
// req: $RequestExtend,
|
|
117
|
+
// res: $ResponseExtend,
|
|
118
|
+
// next: $NextFunctionVer
|
|
119
|
+
// ) {
|
|
120
|
+
// if (_.isError(err)) {
|
|
121
|
+
// if (err.code === 'ECONNABORT' && res.statusCode === HTTP_STATUS.NOT_MODIFIED) {
|
|
122
|
+
// return next();
|
|
123
|
+
// }
|
|
124
|
+
// if (_.isFunction(res.locals.report_error) === false) {
|
|
125
|
+
// // in case of very early error this middleware may not be loaded before error is generated
|
|
126
|
+
// // fixing that
|
|
127
|
+
// errorReportingMiddlewareWrap(req, res, _.noop);
|
|
128
|
+
// }
|
|
129
|
+
// res.locals.report_error(err);
|
|
130
|
+
// } else {
|
|
131
|
+
// // Fall to Middleware.final
|
|
132
|
+
// return next(err);
|
|
133
|
+
// }
|
|
134
|
+
// });
|
|
126
135
|
|
|
127
136
|
app.use(final);
|
|
128
137
|
|
package/test/_helper.ts
CHANGED