@verdaccio/server 6.0.0-6-next.21 → 6.0.0-6-next.25

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 CHANGED
@@ -1,5 +1,104 @@
1
1
  # @verdaccio/server
2
2
 
3
+ ## 6.0.0-6-next.25
4
+
5
+ ### Minor Changes
6
+
7
+ - 048ac95e: feat: align with v5 ui endpoints and ui small bugfix
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [048ac95e]
12
+ - Updated dependencies [730b5d8c]
13
+ - @verdaccio/web@6.0.0-6-next.23
14
+ - @verdaccio/logger@6.0.0-6-next.9
15
+ - @verdaccio/api@6.0.0-6-next.20
16
+ - @verdaccio/auth@6.0.0-6-next.17
17
+ - @verdaccio/loaders@6.0.0-6-next.9
18
+ - @verdaccio/middleware@6.0.0-6-next.17
19
+ - @verdaccio/store@6.0.0-6-next.18
20
+
21
+ ## 6.0.0-6-next.24
22
+
23
+ ### Major Changes
24
+
25
+ - a828271d: refactor: download manifest endpoint and integrate fastify
26
+
27
+ Much simpler API for fetching a package
28
+
29
+ ```
30
+ const manifest = await storage.getPackageNext({
31
+ name,
32
+ uplinksLook: true,
33
+ req,
34
+ version: queryVersion,
35
+ requestOptions,
36
+ });
37
+ ```
38
+
39
+ > not perfect, the `req` still is being passed to the proxy (this has to be refactored at proxy package) and then removed from here, in proxy we pass the request instance to the `request` library.
40
+
41
+ ### Details
42
+
43
+ - `async/await` sugar for getPackage()
44
+ - Improve and reuse code between current implementation and new fastify endpoint (add scaffolding for request manifest)
45
+ - Improve performance
46
+ - Add new tests
47
+
48
+ ### Breaking changes
49
+
50
+ All storage plugins will stop to work since the storage uses `getPackageNext` method which is Promise based, I won't replace this now because will force me to update all plugins, I'll follow up in another PR. Currently will throw http 500
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies [a828271d]
55
+ - Updated dependencies [24b9be02]
56
+ - Updated dependencies [e75c0a3b]
57
+ - Updated dependencies [000d4374]
58
+ - Updated dependencies [b13a3fef]
59
+ - @verdaccio/api@6.0.0-6-next.19
60
+ - @verdaccio/store@6.0.0-6-next.17
61
+ - @verdaccio/utils@6.0.0-6-next.10
62
+ - @verdaccio/core@6.0.0-6-next.4
63
+ - @verdaccio/middleware@6.0.0-6-next.16
64
+ - verdaccio-audit@11.0.0-6-next.8
65
+ - @verdaccio/web@6.0.0-6-next.22
66
+ - @verdaccio/logger@6.0.0-6-next.8
67
+ - @verdaccio/auth@6.0.0-6-next.16
68
+ - @verdaccio/config@6.0.0-6-next.12
69
+ - @verdaccio/loaders@6.0.0-6-next.8
70
+
71
+ ## 6.0.0-6-next.23
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [f86c31ed]
76
+ - Updated dependencies [20c9e43e]
77
+ - @verdaccio/store@6.0.0-6-next.16
78
+ - @verdaccio/utils@6.0.0-6-next.9
79
+ - @verdaccio/web@6.0.0-6-next.21
80
+ - @verdaccio/auth@6.0.0-6-next.15
81
+ - @verdaccio/api@6.0.0-6-next.18
82
+ - @verdaccio/config@6.0.0-6-next.11
83
+ - @verdaccio/middleware@6.0.0-6-next.15
84
+ - @verdaccio/loaders@6.0.0-6-next.7
85
+
86
+ ## 6.0.0-6-next.22
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies [6c1eb021]
91
+ - @verdaccio/core@6.0.0-6-next.3
92
+ - @verdaccio/logger@6.0.0-6-next.7
93
+ - @verdaccio/api@6.0.0-6-next.17
94
+ - @verdaccio/auth@6.0.0-6-next.14
95
+ - @verdaccio/config@6.0.0-6-next.10
96
+ - @verdaccio/loaders@6.0.0-6-next.7
97
+ - @verdaccio/middleware@6.0.0-6-next.14
98
+ - @verdaccio/store@6.0.0-6-next.15
99
+ - @verdaccio/utils@6.0.0-6-next.8
100
+ - @verdaccio/web@6.0.0-6-next.20
101
+
3
102
  ## 6.0.0-6-next.21
4
103
 
5
104
  ### Major Changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/debug/index.ts"],"names":["app","configPath","get","req","res","next","global","gc","pid","process","main","mainModule","filename","conf","mem","memoryUsage"],"mappings":";;;;;;;eAGe,CAACA,GAAD,EAAmBC,UAAnB,KAAgD;AAC7D;AACAD,EAAAA,GAAG,CAACE,GAAJ,CACE,WADF,EAEE,UAAUC,GAAV,EAA+BC,GAA/B,EAAqDC,IAArD,EAAmF;AACjF,QAAIC,MAAM,CAACC,EAAX,EAAe;AACbD,MAAAA,MAAM,CAACC,EAAP;AACD;;AAEDF,IAAAA,IAAI,CAAC;AACHG,MAAAA,GAAG,EAAEC,OAAO,CAACD,GADV;AAEH;AACAE,MAAAA,IAAI,EAAED,OAAO,CAACE,UAAR,CAAmBC,QAHtB;AAIHC,MAAAA,IAAI,EAAEZ,UAJH;AAKHa,MAAAA,GAAG,EAAEL,OAAO,CAACM,WAAR,EALF;AAMHR,MAAAA,EAAE,EAAED,MAAM,CAACC;AANR,KAAD,CAAJ;AAQD,GAfH;AAiBD,C","sourcesContent":["import { Application } from 'express';\nimport { $ResponseExtend, $RequestExtend, $NextFunctionVer } from '../../types/custom';\n\nexport default (app: Application, configPath: string): void => {\n // Hook for tests only\n app.get(\n '/-/_debug',\n function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n if (global.gc) {\n global.gc();\n }\n\n next({\n pid: process.pid,\n // @ts-ignore\n main: process.mainModule.filename,\n conf: configPath,\n mem: process.memoryUsage(),\n gc: global.gc,\n });\n }\n );\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/debug/index.ts"],"names":["app","configPath","get","req","res","next","global","gc","pid","process","main","mainModule","filename","conf","mem","memoryUsage"],"mappings":";;;;;;;eAIe,CAACA,GAAD,EAAmBC,UAAnB,KAAgD;AAC7D;AACAD,EAAAA,GAAG,CAACE,GAAJ,CACE,WADF,EAEE,UAAUC,GAAV,EAA+BC,GAA/B,EAAqDC,IAArD,EAAmF;AACjF,QAAIC,MAAM,CAACC,EAAX,EAAe;AACbD,MAAAA,MAAM,CAACC,EAAP;AACD;;AAEDF,IAAAA,IAAI,CAAC;AACHG,MAAAA,GAAG,EAAEC,OAAO,CAACD,GADV;AAEH;AACAE,MAAAA,IAAI,EAAED,OAAO,CAACE,UAAR,CAAmBC,QAHtB;AAIHC,MAAAA,IAAI,EAAEZ,UAJH;AAKHa,MAAAA,GAAG,EAAEL,OAAO,CAACM,WAAR,EALF;AAMHR,MAAAA,EAAE,EAAED,MAAM,CAACC;AANR,KAAD,CAAJ;AAQD,GAfH;AAiBD,C","sourcesContent":["import { Application } from 'express';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../../types/custom';\n\nexport default (app: Application, configPath: string): void => {\n // Hook for tests only\n app.get(\n '/-/_debug',\n function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n if (global.gc) {\n global.gc();\n }\n\n next({\n pid: process.pid,\n // @ts-ignore\n main: process.mainModule.filename,\n conf: configPath,\n mem: process.memoryUsage(),\n gc: global.gc,\n });\n }\n );\n};\n"],"file":"index.js"}
package/build/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ConfigRuntime } from '@verdaccio/types';
2
1
  import { IBasicAuth } from '@verdaccio/auth';
3
2
  import { Storage } from '@verdaccio/store';
3
+ import { ConfigRuntime } from '@verdaccio/types';
4
4
  import { IPlugin } from '@verdaccio/types';
5
5
  export interface IPluginMiddleware<T> extends IPlugin<T> {
6
6
  register_middlewares(app: any, auth: IBasicAuth<T>, storage: Storage): void;
package/build/server.js CHANGED
@@ -5,48 +5,42 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _lodash = _interopRequireDefault(require("lodash"));
8
+ var _compression = _interopRequireDefault(require("compression"));
9
9
 
10
- var _express = _interopRequireDefault(require("express"));
10
+ var _cors = _interopRequireDefault(require("cors"));
11
11
 
12
12
  var _debug = _interopRequireDefault(require("debug"));
13
13
 
14
- var _compression = _interopRequireDefault(require("compression"));
15
-
16
- var _cors = _interopRequireDefault(require("cors"));
14
+ var _express = _interopRequireDefault(require("express"));
17
15
 
18
16
  var _expressRateLimit = _interopRequireDefault(require("express-rate-limit"));
19
17
 
20
- var _loaders = require("@verdaccio/loaders");
18
+ var _lodash = _interopRequireDefault(require("lodash"));
21
19
 
22
- var _auth = require("@verdaccio/auth");
20
+ var _verdaccioAudit = _interopRequireDefault(require("verdaccio-audit"));
23
21
 
24
22
  var _api = _interopRequireDefault(require("@verdaccio/api"));
25
23
 
26
- var _core = require("@verdaccio/core");
24
+ var _auth = require("@verdaccio/auth");
27
25
 
28
26
  var _config = require("@verdaccio/config");
29
27
 
30
- var _web = _interopRequireDefault(require("@verdaccio/web"));
28
+ var _core = require("@verdaccio/core");
31
29
 
32
- var _store = require("@verdaccio/store");
30
+ var _loaders = require("@verdaccio/loaders");
33
31
 
34
32
  var _logger = require("@verdaccio/logger");
35
33
 
36
34
  var _middleware = require("@verdaccio/middleware");
37
35
 
38
- var _verdaccioAudit = _interopRequireDefault(require("verdaccio-audit"));
36
+ var _store = require("@verdaccio/store");
37
+
38
+ var _web = _interopRequireDefault(require("@verdaccio/web"));
39
39
 
40
40
  var _debug2 = _interopRequireDefault(require("./debug"));
41
41
 
42
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
43
 
44
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
45
-
46
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
47
-
48
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
49
-
50
44
  const debug = (0, _debug.default)('verdaccio:server');
51
45
 
52
46
  const defineAPI = function (config, storage) {
@@ -85,10 +79,10 @@ const defineAPI = function (config, storage) {
85
79
  });
86
80
 
87
81
  if (_lodash.default.isEmpty(plugins)) {
88
- plugins.push(new _verdaccioAudit.default(_objectSpread(_objectSpread({}, config), {}, {
82
+ plugins.push(new _verdaccioAudit.default({ ...config,
89
83
  enabled: true,
90
84
  strict_ssl: true
91
- }), {
85
+ }, {
92
86
  config,
93
87
  logger: _logger.logger
94
88
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"names":["debug","defineAPI","config","storage","auth","Auth","app","limiter","RateLimit","serverSettings","rateLimit","set","process","env","NODE_ENV","use","log","errorReportingMiddleware","req","res","next","setHeader","user_agent","get","url","_debug","config_path","plugin_params","logger","plugins","middlewares","plugin","register_middlewares","_","isEmpty","push","AuditMiddleware","enabled","strict_ssl","forEach","errorUtils","getNotFound","API_ERROR","WEB_DISABLED","FILE_NOT_FOUND","err","isError","code","statusCode","HTTP_STATUS","NOT_MODIFIED","isFunction","locals","report_error","noop","final","configHash","AppConfig","cloneDeep","filters","filter_metadata","Storage","init","error","msg","Error"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;;;;;;;;;AAMA,MAAMA,KAAK,GAAG,oBAAW,kBAAX,CAAd;;AAEA,MAAMC,SAAS,GAAG,UAAUC,MAAV,EAA2BC,OAA3B,EAAkD;AAClE,QAAMC,IAAW,GAAG,IAAIC,UAAJ,CAASH,MAAT,CAApB;AACA,QAAMI,GAAgB,GAAG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AAO,CAAC2D,IAAR,CAAa5D,MAAb,EAAqByD,OAArB,CAAN;AACA3D,IAAAA,KAAK,CAAC,kBAAD,CAAL;AACD,GALD,CAKE,OAAO6C,GAAP,EAAiB;AACjBjB,mBAAOmC,KAAP,CAAa;AAAEA,MAAAA,KAAK,EAAElB,GAAG,CAACmB;AAAb,KAAb,EAAiC,8BAAjC;;AACA,UAAM,IAAIC,KAAJ,CAAUpB,GAAV,CAAN;AACD;;AACD,SAAO5C,SAAS,CAACC,MAAD,EAASC,OAAT,CAAhB;AACD,C","sourcesContent":["import _ from 'lodash';\nimport express, { Application } from 'express';\nimport buildDebug from 'debug';\nimport compression from 'compression';\nimport cors from 'cors';\nimport RateLimit from 'express-rate-limit';\nimport { HttpError } from 'http-errors';\n\nimport { loadPlugin } from '@verdaccio/loaders';\nimport { Auth } from '@verdaccio/auth';\nimport apiEndpoint from '@verdaccio/api';\nimport { API_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';\nimport { Config as AppConfig } from '@verdaccio/config';\n\nimport webMiddleware from '@verdaccio/web';\nimport { ConfigRuntime } from '@verdaccio/types';\n\nimport { IAuth, IBasicAuth } from '@verdaccio/auth';\nimport { Storage } from '@verdaccio/store';\nimport { logger } from '@verdaccio/logger';\nimport { log, final, errorReportingMiddleware } from '@verdaccio/middleware';\nimport AuditMiddleware from 'verdaccio-audit';\n\nimport { Config as IConfig, IPluginStorageFilter, IPlugin } from '@verdaccio/types';\nimport { $ResponseExtend, $RequestExtend, $NextFunctionVer } from '../types/custom';\n\nimport hookDebug from './debug';\n\nexport interface IPluginMiddleware<T> extends IPlugin<T> {\n register_middlewares(app: any, auth: IBasicAuth<T>, storage: Storage): void;\n}\n\nconst debug = buildDebug('verdaccio:server');\n\nconst defineAPI = function (config: IConfig, storage: Storage): any {\n const auth: IAuth = new Auth(config);\n const app: Application = express();\n const limiter = new RateLimit(config.serverSettings.rateLimit);\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 app.use(cors());\n app.use(limiter);\n\n // Router setup\n app.use(log);\n app.use(errorReportingMiddleware);\n app.use(function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n res.setHeader('X-Powered-By', config.user_agent);\n next();\n });\n\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.png';\n next();\n }\n );\n\n // Hook for tests only\n if (config._debug) {\n hookDebug(app, config.config_path);\n }\n\n // register middleware plugins\n const plugin_params = {\n config: config,\n logger: logger,\n };\n\n const plugins: IPluginMiddleware<IConfig>[] = loadPlugin(\n config,\n config.middlewares,\n plugin_params,\n function (plugin: IPluginMiddleware<IConfig>) {\n return plugin.register_middlewares;\n }\n );\n\n if (_.isEmpty(plugins)) {\n plugins.push(\n new AuditMiddleware(\n { ...config, enabled: true, strict_ssl: true },\n { config, logger: logger }\n )\n );\n }\n\n plugins.forEach((plugin: IPluginMiddleware<IConfig>) => {\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(webMiddleware(config, auth, storage));\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(API_ERROR.FILE_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 errorReportingMiddleware(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 (configHash: ConfigRuntime): Promise<any> {\n debug('start server');\n const config: IConfig = new AppConfig(_.cloneDeep(configHash));\n // register middleware plugins\n const plugin_params = {\n config: config,\n logger: logger,\n };\n const filters = loadPlugin(\n config,\n config.filters || {},\n plugin_params,\n (plugin: IPluginStorageFilter<IConfig>) => plugin.filter_metadata\n );\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, filters);\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 defineAPI(config, storage);\n});\n"],"file":"server.js"}
1
+ {"version":3,"sources":["../src/server.ts"],"names":["debug","defineAPI","config","storage","auth","Auth","app","limiter","RateLimit","serverSettings","rateLimit","set","process","env","NODE_ENV","use","log","errorReportingMiddleware","req","res","next","setHeader","user_agent","get","url","_debug","config_path","plugin_params","logger","plugins","middlewares","plugin","register_middlewares","_","isEmpty","push","AuditMiddleware","enabled","strict_ssl","forEach","errorUtils","getNotFound","API_ERROR","WEB_DISABLED","FILE_NOT_FOUND","err","isError","code","statusCode","HTTP_STATUS","NOT_MODIFIED","isFunction","locals","report_error","noop","final","configHash","AppConfig","cloneDeep","filters","filter_metadata","Storage","init","error","msg","Error"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AAGA;;;;AAMA,MAAMA,KAAK,GAAG,oBAAW,kBAAX,CAAd;;AAEA,MAAMC,SAAS,GAAG,UAAUC,MAAV,EAA2BC,OAA3B,EAAkD;AAClE,QAAMC,IAAU,GAAG,IAAIC,UAAJ,CAASH,MAAT,CAAnB;AACA,QAAMI,GA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C,oBAAD,CAAL;AACA,UAAMG,OAAO,CAAC2D,IAAR,CAAa5D,MAAb,EAAqByD,OAArB,CAAN;AACA3D,IAAAA,KAAK,CAAC,kBAAD,CAAL;AACD,GALD,CAKE,OAAO6C,GAAP,EAAiB;AACjBjB,mBAAOmC,KAAP,CAAa;AAAEA,MAAAA,KAAK,EAAElB,GAAG,CAACmB;AAAb,KAAb,EAAiC,8BAAjC;;AACA,UAAM,IAAIC,KAAJ,CAAUpB,GAAV,CAAN;AACD;;AACD,SAAO5C,SAAS,CAACC,MAAD,EAASC,OAAT,CAAhB;AACD,C","sourcesContent":["import compression from 'compression';\nimport cors from 'cors';\nimport buildDebug from 'debug';\nimport express, { Application } from 'express';\nimport RateLimit from 'express-rate-limit';\nimport { HttpError } from 'http-errors';\nimport _ from 'lodash';\nimport AuditMiddleware from 'verdaccio-audit';\n\nimport apiEndpoint from '@verdaccio/api';\nimport { Auth, IBasicAuth } from '@verdaccio/auth';\nimport { Config as AppConfig } from '@verdaccio/config';\nimport { API_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';\nimport { loadPlugin } from '@verdaccio/loaders';\nimport { logger } from '@verdaccio/logger';\nimport { errorReportingMiddleware, final, log } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { ConfigRuntime } from '@verdaccio/types';\nimport { Config as IConfig, IPlugin, IPluginStorageFilter } from '@verdaccio/types';\nimport webMiddleware from '@verdaccio/web';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\nimport hookDebug from './debug';\n\nexport interface IPluginMiddleware<T> extends IPlugin<T> {\n register_middlewares(app: any, auth: IBasicAuth<T>, storage: Storage): void;\n}\n\nconst debug = buildDebug('verdaccio:server');\n\nconst defineAPI = function (config: IConfig, storage: Storage): any {\n const auth: Auth = new Auth(config);\n const app: Application = express();\n const limiter = new RateLimit(config.serverSettings.rateLimit);\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 app.use(cors());\n app.use(limiter);\n\n // Router setup\n app.use(log);\n app.use(errorReportingMiddleware);\n app.use(function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n res.setHeader('X-Powered-By', config.user_agent);\n next();\n });\n\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.png';\n next();\n }\n );\n\n // Hook for tests only\n if (config._debug) {\n hookDebug(app, config.config_path);\n }\n\n // register middleware plugins\n const plugin_params = {\n config: config,\n logger: logger,\n };\n\n const plugins: IPluginMiddleware<IConfig>[] = loadPlugin(\n config,\n config.middlewares,\n plugin_params,\n function (plugin: IPluginMiddleware<IConfig>) {\n return plugin.register_middlewares;\n }\n );\n\n if (_.isEmpty(plugins)) {\n plugins.push(\n new AuditMiddleware(\n { ...config, enabled: true, strict_ssl: true },\n { config, logger: logger }\n )\n );\n }\n\n plugins.forEach((plugin: IPluginMiddleware<IConfig>) => {\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(webMiddleware(config, auth, storage));\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(API_ERROR.FILE_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 errorReportingMiddleware(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 (configHash: ConfigRuntime): Promise<any> {\n debug('start server');\n const config: IConfig = new AppConfig(_.cloneDeep(configHash));\n // register middleware plugins\n const plugin_params = {\n config: config,\n logger: logger,\n };\n const filters = loadPlugin(\n config,\n config.filters || {},\n plugin_params,\n (plugin: IPluginStorageFilter<IConfig>) => plugin.filter_metadata\n );\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, filters);\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 defineAPI(config, storage);\n});\n"],"file":"server.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/server",
3
- "version": "6.0.0-6-next.21",
3
+ "version": "6.0.0-6-next.25",
4
4
  "description": "server logic",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -30,31 +30,31 @@
30
30
  "npm": ">=6"
31
31
  },
32
32
  "dependencies": {
33
- "@verdaccio/api": "6.0.0-6-next.16",
34
- "@verdaccio/auth": "6.0.0-6-next.13",
35
- "@verdaccio/core": "6.0.0-6-next.2",
36
- "@verdaccio/config": "6.0.0-6-next.9",
37
- "@verdaccio/loaders": "6.0.0-6-next.6",
38
- "@verdaccio/logger": "6.0.0-6-next.6",
39
- "@verdaccio/middleware": "6.0.0-6-next.13",
40
- "@verdaccio/store": "6.0.0-6-next.14",
41
- "@verdaccio/utils": "6.0.0-6-next.7",
42
- "@verdaccio/web": "6.0.0-6-next.19",
43
- "verdaccio-audit": "11.0.0-6-next.7",
33
+ "@verdaccio/api": "6.0.0-6-next.20",
34
+ "@verdaccio/auth": "6.0.0-6-next.17",
35
+ "@verdaccio/core": "6.0.0-6-next.4",
36
+ "@verdaccio/config": "6.0.0-6-next.12",
37
+ "@verdaccio/loaders": "6.0.0-6-next.9",
38
+ "@verdaccio/logger": "6.0.0-6-next.9",
39
+ "@verdaccio/middleware": "6.0.0-6-next.17",
40
+ "@verdaccio/store": "6.0.0-6-next.18",
41
+ "@verdaccio/utils": "6.0.0-6-next.10",
42
+ "@verdaccio/web": "6.0.0-6-next.23",
43
+ "verdaccio-audit": "11.0.0-6-next.8",
44
44
  "compression": "1.7.4",
45
45
  "cors": "2.8.5",
46
- "debug": "4.3.2",
47
- "express": "4.17.1",
48
- "express-rate-limit": "5.3.0",
46
+ "debug": "4.3.3",
47
+ "express": "4.17.2",
48
+ "express-rate-limit": "5.5.1",
49
49
  "lodash": "4.17.21"
50
50
  },
51
51
  "devDependencies": {
52
- "@types/node": "16.9.1",
53
- "@verdaccio/mock": "6.0.0-6-next.10",
54
- "@verdaccio/proxy": "6.0.0-6-next.13",
52
+ "@types/node": "16.11.19",
53
+ "@verdaccio/mock": "6.0.0-6-next.13",
54
+ "@verdaccio/proxy": "6.0.0-6-next.17",
55
55
  "@verdaccio/helper": "1.0.0",
56
- "http-errors": "1.8.0",
57
- "request": "2.87.0"
56
+ "http-errors": "1.8.1",
57
+ "request": "2.88.0"
58
58
  },
59
59
  "funding": {
60
60
  "type": "opencollective",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "scripts": {
64
64
  "clean": "rimraf ./build",
65
- "test": "cross-env NODE_ENV=test BABEL_ENV=test jest",
65
+ "test": "cross-env NODE_ENV=test BABEL_ENV=test jest --detectOpenHandles",
66
66
  "type-check": "tsc --noEmit -p tsconfig.build.json",
67
67
  "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
68
68
  "watch": "pnpm build:js -- --watch",
@@ -1,5 +1,6 @@
1
1
  import { Application } from 'express';
2
- import { $ResponseExtend, $RequestExtend, $NextFunctionVer } from '../../types/custom';
2
+
3
+ import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../../types/custom';
3
4
 
4
5
  export default (app: Application, configPath: string): void => {
5
6
  // Hook for tests only
package/src/server.ts CHANGED
@@ -1,29 +1,25 @@
1
- import _ from 'lodash';
2
- import express, { Application } from 'express';
3
- import buildDebug from 'debug';
4
1
  import compression from 'compression';
5
2
  import cors from 'cors';
3
+ import buildDebug from 'debug';
4
+ import express, { Application } from 'express';
6
5
  import RateLimit from 'express-rate-limit';
7
6
  import { HttpError } from 'http-errors';
7
+ import _ from 'lodash';
8
+ import AuditMiddleware from 'verdaccio-audit';
8
9
 
9
- import { loadPlugin } from '@verdaccio/loaders';
10
- import { Auth } from '@verdaccio/auth';
11
10
  import apiEndpoint from '@verdaccio/api';
12
- import { API_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';
11
+ import { Auth, IBasicAuth } from '@verdaccio/auth';
13
12
  import { Config as AppConfig } from '@verdaccio/config';
14
-
15
- import webMiddleware from '@verdaccio/web';
16
- import { ConfigRuntime } from '@verdaccio/types';
17
-
18
- import { IAuth, IBasicAuth } from '@verdaccio/auth';
19
- import { Storage } from '@verdaccio/store';
13
+ import { API_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';
14
+ import { loadPlugin } from '@verdaccio/loaders';
20
15
  import { logger } from '@verdaccio/logger';
21
- import { log, final, errorReportingMiddleware } from '@verdaccio/middleware';
22
- import AuditMiddleware from 'verdaccio-audit';
23
-
24
- import { Config as IConfig, IPluginStorageFilter, IPlugin } from '@verdaccio/types';
25
- import { $ResponseExtend, $RequestExtend, $NextFunctionVer } from '../types/custom';
16
+ import { errorReportingMiddleware, final, log } from '@verdaccio/middleware';
17
+ import { Storage } from '@verdaccio/store';
18
+ import { ConfigRuntime } from '@verdaccio/types';
19
+ import { Config as IConfig, IPlugin, IPluginStorageFilter } from '@verdaccio/types';
20
+ import webMiddleware from '@verdaccio/web';
26
21
 
22
+ import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
27
23
  import hookDebug from './debug';
28
24
 
29
25
  export interface IPluginMiddleware<T> extends IPlugin<T> {
@@ -33,7 +29,7 @@ export interface IPluginMiddleware<T> extends IPlugin<T> {
33
29
  const debug = buildDebug('verdaccio:server');
34
30
 
35
31
  const defineAPI = function (config: IConfig, storage: Storage): any {
36
- const auth: IAuth = new Auth(config);
32
+ const auth: Auth = new Auth(config);
37
33
  const app: Application = express();
38
34
  const limiter = new RateLimit(config.serverSettings.rateLimit);
39
35
  // run in production mode by default, just in case
@@ -1,24 +1,22 @@
1
+ import _ from 'lodash';
1
2
  import path from 'path';
2
3
  import request from 'supertest';
3
- import _ from 'lodash';
4
-
5
- import { HEADERS, HTTP_STATUS, HEADER_TYPE, API_MESSAGE, TOKEN_BEARER } from '@verdaccio/core';
6
- // import { generatePackageMetadata } from '@verdaccio/helper';
7
- import { buildToken } from '@verdaccio/utils';
8
- import { setup, logger } from '@verdaccio/logger';
9
4
 
5
+ import { API_MESSAGE, HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BEARER } from '@verdaccio/core';
6
+ import { logger, setup } from '@verdaccio/logger';
10
7
  import { mockServer } from '@verdaccio/mock';
11
-
12
8
  import {
13
- configExample,
14
9
  DOMAIN_SERVERS,
10
+ configExample,
11
+ generateRamdonStorage,
12
+ generateUnPublishURI,
15
13
  getNewToken,
16
14
  getPackage,
17
15
  putPackage,
18
- generateRamdonStorage,
19
16
  verifyPackageVersionDoesExist,
20
- generateUnPublishURI,
21
17
  } from '@verdaccio/mock';
18
+ // import { generatePackageMetadata } from '@verdaccio/helper';
19
+ import { buildToken } from '@verdaccio/utils';
22
20
 
23
21
  import endPointAPI from '../../src';
24
22
  import publishMetadata from './helpers/publish-api';
@@ -1,9 +1,9 @@
1
- import path from 'path';
2
1
  import express from 'express';
2
+ import path from 'path';
3
3
  import request from 'request';
4
4
 
5
- import { API_ERROR } from '@verdaccio/core';
6
5
  import { parseConfigFile } from '@verdaccio/config';
6
+ import { API_ERROR } from '@verdaccio/core';
7
7
  import { setup } from '@verdaccio/logger';
8
8
 
9
9
  import endPointAPI from '../../src';
@@ -2,24 +2,23 @@ import path from 'path';
2
2
  import request from 'supertest';
3
3
 
4
4
  import {
5
+ API_ERROR,
5
6
  HEADERS,
6
- HTTP_STATUS,
7
7
  HEADER_TYPE,
8
- TOKEN_BEARER,
8
+ HTTP_STATUS,
9
9
  TOKEN_BASIC,
10
- API_ERROR,
10
+ TOKEN_BEARER,
11
11
  } from '@verdaccio/core';
12
- import { mockServer, generateRamdonStorage } from '@verdaccio/mock';
13
- import { buildUserBuffer, buildToken } from '@verdaccio/utils';
12
+ import { logger, setup } from '@verdaccio/logger';
13
+ import { generateRamdonStorage, mockServer } from '@verdaccio/mock';
14
14
  import {
15
- configExample,
16
15
  DOMAIN_SERVERS,
17
16
  addUser,
17
+ configExample,
18
18
  getPackage,
19
19
  loginUserToken,
20
20
  } from '@verdaccio/mock';
21
-
22
- import { setup, logger } from '@verdaccio/logger';
21
+ import { buildToken, buildUserBuffer } from '@verdaccio/utils';
23
22
 
24
23
  import endPointAPI from '../../src';
25
24
 
@@ -1,14 +1,14 @@
1
1
  import path from 'path';
2
2
  import request from 'supertest';
3
3
 
4
- import { setup, logger } from '@verdaccio/logger';
5
-
6
- setup([]);
7
-
8
4
  import { HEADERS, HTTP_STATUS } from '@verdaccio/core';
9
- import { generateRamdonStorage, mockServer, configExample, DOMAIN_SERVERS } from '@verdaccio/mock';
5
+ import { logger, setup } from '@verdaccio/logger';
6
+ import { DOMAIN_SERVERS, configExample, generateRamdonStorage, mockServer } from '@verdaccio/mock';
7
+
10
8
  import endPointAPI from '../../src';
11
9
 
10
+ setup([]);
11
+
12
12
  describe('api with no limited access configuration', () => {
13
13
  let app;
14
14
  let mockRegistry;
@@ -1,17 +1,16 @@
1
1
  import path from 'path';
2
2
  import request from 'supertest';
3
3
 
4
- import { mockServer } from '@verdaccio/mock';
5
4
  import { API_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '@verdaccio/core';
6
- import { setup, logger } from '@verdaccio/logger';
7
-
5
+ import { logger, setup } from '@verdaccio/logger';
6
+ import { mockServer } from '@verdaccio/mock';
8
7
  import {
8
+ DOMAIN_SERVERS,
9
+ configExample,
9
10
  generateRamdonStorage,
10
11
  getNewToken,
11
12
  getProfile,
12
13
  postProfile,
13
- configExample,
14
- DOMAIN_SERVERS,
15
14
  } from '@verdaccio/mock';
16
15
 
17
16
  import endPointAPI from '../../src';
@@ -1,14 +1,13 @@
1
- import path from 'path';
2
1
  import fs from 'fs';
2
+ import path from 'path';
3
3
  import { Writable } from 'stream';
4
+
4
5
  import { Config as AppConfig } from '@verdaccio/config';
6
+ import { API_ERROR, HTTP_STATUS } from '@verdaccio/core';
7
+ import { logger, setup } from '@verdaccio/logger';
8
+ import { DOMAIN_SERVERS, configExample, generateRamdonStorage, mockServer } from '@verdaccio/mock';
5
9
  import { Storage } from '@verdaccio/store';
6
-
7
10
  import { Config } from '@verdaccio/types';
8
- import { API_ERROR, HTTP_STATUS } from '@verdaccio/core';
9
- import { mockServer, configExample, DOMAIN_SERVERS, generateRamdonStorage } from '@verdaccio/mock';
10
-
11
- import { setup, logger } from '@verdaccio/logger';
12
11
 
13
12
  setup([]);
14
13
 
@@ -120,7 +119,7 @@ describe('StorageTest', () => {
120
119
  expect(notcachedSpy).toHaveBeenCalledTimes(0);
121
120
  expect(cachedSpy).toHaveBeenCalledTimes(1);
122
121
  expect(cachedSpy).toHaveBeenCalledWith(
123
- 'http://0.0.0.0:55548/jquery/-/jquery-1.5.1.tgz'
122
+ 'http://localhost:55548/jquery/-/jquery-1.5.1.tgz'
124
123
  );
125
124
  res();
126
125
  });
@@ -140,7 +139,7 @@ describe('StorageTest', () => {
140
139
  expect(cachedSpy).toHaveBeenCalledTimes(0);
141
140
  expect(notcachedSpy).toHaveBeenCalledTimes(1);
142
141
  expect(notcachedSpy).toHaveBeenCalledWith(
143
- 'http://0.0.0.0:55548/@jquery%2fjquery/-/jquery-1.5.1.tgz'
142
+ 'http://localhost:55548/@jquery%2fjquery/-/jquery-1.5.1.tgz'
144
143
  );
145
144
  res();
146
145
  });
@@ -1,26 +1,24 @@
1
+ import _ from 'lodash';
1
2
  import path from 'path';
2
3
  import request from 'supertest';
3
- import _ from 'lodash';
4
4
 
5
5
  import {
6
+ API_ERROR,
6
7
  HEADERS,
7
- HTTP_STATUS,
8
8
  HEADER_TYPE,
9
- TOKEN_BEARER,
10
- API_ERROR,
9
+ HTTP_STATUS,
11
10
  SUPPORT_ERRORS,
11
+ TOKEN_BEARER,
12
12
  } from '@verdaccio/core';
13
-
14
- import { buildToken } from '@verdaccio/utils';
13
+ import { logger, setup } from '@verdaccio/logger';
15
14
  import {
16
- generateRamdonStorage,
17
15
  DOMAIN_SERVERS,
18
- mockServer,
19
- getNewToken,
20
16
  configExample,
17
+ generateRamdonStorage,
18
+ getNewToken,
19
+ mockServer,
21
20
  } from '@verdaccio/mock';
22
-
23
- import { setup, logger } from '@verdaccio/logger';
21
+ import { buildToken } from '@verdaccio/utils';
24
22
 
25
23
  import endPointAPI from '../../src';
26
24
 
@@ -1,11 +1,10 @@
1
1
  import path from 'path';
2
2
  import request from 'supertest';
3
3
 
4
- import { HEADERS, HTTP_STATUS, HEADER_TYPE, DIST_TAGS } from '@verdaccio/core';
4
+ import { DIST_TAGS, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
5
+ import { logger, setup } from '@verdaccio/logger';
6
+ import { DOMAIN_SERVERS, configExample, generateRamdonStorage, mockServer } from '@verdaccio/mock';
5
7
 
6
- import { mockServer, DOMAIN_SERVERS, configExample, generateRamdonStorage } from '@verdaccio/mock';
7
-
8
- import { setup, logger } from '@verdaccio/logger';
9
8
  import endPointAPI from '../../src';
10
9
  import forbiddenPlace from './partials/forbidden-place';
11
10
  import publishMetadata from './partials/publish-api';
@@ -64,7 +63,7 @@ describe('endpoint web unit test', () => {
64
63
  test('should display sidebar info', () => {
65
64
  return new Promise((resolve) => {
66
65
  request(app)
67
- .get('/-/verdaccio/sidebar/@scope/pk1-test')
66
+ .get('/-/verdaccio/data/sidebar/@scope/pk1-test')
68
67
  .expect(HTTP_STATUS.OK)
69
68
  .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
70
69
  .end(function (err, res) {
@@ -86,7 +85,7 @@ describe('endpoint web unit test', () => {
86
85
  test('should display sidebar info by version', () => {
87
86
  return new Promise((resolve) => {
88
87
  request(app)
89
- .get('/-/verdaccio/sidebar/@scope/pk1-test?v=1.0.6')
88
+ .get('/-/verdaccio/data/sidebar/@scope/pk1-test?v=1.0.6')
90
89
  .expect(HTTP_STATUS.OK)
91
90
  .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
92
91
  .end(function (err, res) {
@@ -105,7 +104,7 @@ describe('endpoint web unit test', () => {
105
104
  test('should display sidebar info 404', () => {
106
105
  return new Promise((resolve) => {
107
106
  request(app)
108
- .get('/-/verdaccio/sidebar/@scope/404')
107
+ .get('/-/verdaccio/data/sidebar/@scope/404')
109
108
  .expect(HTTP_STATUS.NOT_FOUND)
110
109
  .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
111
110
  .end(function () {
@@ -117,7 +116,7 @@ describe('endpoint web unit test', () => {
117
116
  test('should display sidebar info 404 with version', () => {
118
117
  return new Promise((resolve) => {
119
118
  request(app)
120
- .get('/-/verdaccio/sidebar/@scope/pk1-test?v=0.0.0-not-found')
119
+ .get('/-/verdaccio/data/sidebar/@scope/pk1-test?v=0.0.0-not-found')
121
120
  .expect(HTTP_STATUS.NOT_FOUND)
122
121
  .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
123
122
  .end(function () {
@@ -131,7 +130,7 @@ describe('endpoint web unit test', () => {
131
130
  test('should find @scope/pk1-test', () => {
132
131
  return new Promise((resolve) => {
133
132
  request(app)
134
- .get('/-/verdaccio/search/@scope%2fpk1-test')
133
+ .get('/-/verdaccio/data/search/@scope%2fpk1-test')
135
134
  .expect(HTTP_STATUS.OK)
136
135
  .end(function (_err, res) {
137
136
  expect(res.body).toHaveLength(1);
@@ -143,7 +142,7 @@ describe('endpoint web unit test', () => {
143
142
  test('should not find forbidden-place', () => {
144
143
  return new Promise((resolve) => {
145
144
  request(app)
146
- .get('/-/verdaccio/search/forbidden-place')
145
+ .get('/-/verdaccio/data/search/forbidden-place')
147
146
  .expect(HTTP_STATUS.OK)
148
147
  .end(function (err, res) {
149
148
  // this is expected since we are not logged
package/types/custom.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Logger, RemoteUser } from '@verdaccio/types';
2
1
  import { NextFunction, Request, Response } from 'express';
3
2
 
3
+ import { Logger, RemoteUser } from '@verdaccio/types';
4
+
4
5
  export type $RequestExtend = Request & { remote_user?: any; log: Logger };
5
6
  export type $ResponseExtend = Response & { cookies?: any };
6
7
  export type $NextFunctionVer = NextFunction & any;