@verdaccio/server 6.0.0-6-next.23 → 6.0.0-6-next.26

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,86 @@
1
1
  # @verdaccio/server
2
2
 
3
+ ## 6.0.0-6-next.26
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [b78f3525]
8
+ - @verdaccio/logger@6.0.0-6-next.10
9
+ - @verdaccio/api@6.0.0-6-next.21
10
+ - @verdaccio/auth@6.0.0-6-next.18
11
+ - @verdaccio/loaders@6.0.0-6-next.10
12
+ - @verdaccio/middleware@6.0.0-6-next.18
13
+ - @verdaccio/store@6.0.0-6-next.19
14
+ - @verdaccio/web@6.0.0-6-next.24
15
+
16
+ ## 6.0.0-6-next.25
17
+
18
+ ### Minor Changes
19
+
20
+ - 048ac95e: feat: align with v5 ui endpoints and ui small bugfix
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [048ac95e]
25
+ - Updated dependencies [730b5d8c]
26
+ - @verdaccio/web@6.0.0-6-next.23
27
+ - @verdaccio/logger@6.0.0-6-next.9
28
+ - @verdaccio/api@6.0.0-6-next.20
29
+ - @verdaccio/auth@6.0.0-6-next.17
30
+ - @verdaccio/loaders@6.0.0-6-next.9
31
+ - @verdaccio/middleware@6.0.0-6-next.17
32
+ - @verdaccio/store@6.0.0-6-next.18
33
+
34
+ ## 6.0.0-6-next.24
35
+
36
+ ### Major Changes
37
+
38
+ - a828271d: refactor: download manifest endpoint and integrate fastify
39
+
40
+ Much simpler API for fetching a package
41
+
42
+ ```
43
+ const manifest = await storage.getPackageNext({
44
+ name,
45
+ uplinksLook: true,
46
+ req,
47
+ version: queryVersion,
48
+ requestOptions,
49
+ });
50
+ ```
51
+
52
+ > 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.
53
+
54
+ ### Details
55
+
56
+ - `async/await` sugar for getPackage()
57
+ - Improve and reuse code between current implementation and new fastify endpoint (add scaffolding for request manifest)
58
+ - Improve performance
59
+ - Add new tests
60
+
61
+ ### Breaking changes
62
+
63
+ 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
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [a828271d]
68
+ - Updated dependencies [24b9be02]
69
+ - Updated dependencies [e75c0a3b]
70
+ - Updated dependencies [000d4374]
71
+ - Updated dependencies [b13a3fef]
72
+ - @verdaccio/api@6.0.0-6-next.19
73
+ - @verdaccio/store@6.0.0-6-next.17
74
+ - @verdaccio/utils@6.0.0-6-next.10
75
+ - @verdaccio/core@6.0.0-6-next.4
76
+ - @verdaccio/middleware@6.0.0-6-next.16
77
+ - verdaccio-audit@11.0.0-6-next.8
78
+ - @verdaccio/web@6.0.0-6-next.22
79
+ - @verdaccio/logger@6.0.0-6-next.8
80
+ - @verdaccio/auth@6.0.0-6-next.16
81
+ - @verdaccio/config@6.0.0-6-next.12
82
+ - @verdaccio/loaders@6.0.0-6-next.8
83
+
3
84
  ## 6.0.0-6-next.23
4
85
 
5
86
  ### Patch Changes
package/build/server.js CHANGED
@@ -41,12 +41,6 @@ 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;;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,IAAI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;AACAF,IAAAA,KAAK,CAAC,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"}
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,CAA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,IAAAA,KAAK,CAAC,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.23",
3
+ "version": "6.0.0-6-next.26",
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.18",
34
- "@verdaccio/auth": "6.0.0-6-next.15",
35
- "@verdaccio/core": "6.0.0-6-next.3",
36
- "@verdaccio/config": "6.0.0-6-next.11",
37
- "@verdaccio/loaders": "6.0.0-6-next.7",
38
- "@verdaccio/logger": "6.0.0-6-next.7",
39
- "@verdaccio/middleware": "6.0.0-6-next.15",
40
- "@verdaccio/store": "6.0.0-6-next.16",
41
- "@verdaccio/utils": "6.0.0-6-next.9",
42
- "@verdaccio/web": "6.0.0-6-next.21",
43
- "verdaccio-audit": "11.0.0-6-next.7",
33
+ "@verdaccio/api": "6.0.0-6-next.21",
34
+ "@verdaccio/auth": "6.0.0-6-next.18",
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.10",
38
+ "@verdaccio/logger": "6.0.0-6-next.10",
39
+ "@verdaccio/middleware": "6.0.0-6-next.18",
40
+ "@verdaccio/store": "6.0.0-6-next.19",
41
+ "@verdaccio/utils": "6.0.0-6-next.10",
42
+ "@verdaccio/web": "6.0.0-6-next.24",
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.11.6",
53
- "@verdaccio/mock": "6.0.0-6-next.12",
54
- "@verdaccio/proxy": "6.0.0-6-next.15",
52
+ "@types/node": "16.11.21",
53
+ "@verdaccio/mock": "6.0.0-6-next.13",
54
+ "@verdaccio/proxy": "6.0.0-6-next.18",
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",
@@ -119,7 +119,7 @@ describe('StorageTest', () => {
119
119
  expect(notcachedSpy).toHaveBeenCalledTimes(0);
120
120
  expect(cachedSpy).toHaveBeenCalledTimes(1);
121
121
  expect(cachedSpy).toHaveBeenCalledWith(
122
- 'http://0.0.0.0:55548/jquery/-/jquery-1.5.1.tgz'
122
+ 'http://localhost:55548/jquery/-/jquery-1.5.1.tgz'
123
123
  );
124
124
  res();
125
125
  });
@@ -139,7 +139,7 @@ describe('StorageTest', () => {
139
139
  expect(cachedSpy).toHaveBeenCalledTimes(0);
140
140
  expect(notcachedSpy).toHaveBeenCalledTimes(1);
141
141
  expect(notcachedSpy).toHaveBeenCalledWith(
142
- 'http://0.0.0.0:55548/@jquery%2fjquery/-/jquery-1.5.1.tgz'
142
+ 'http://localhost:55548/@jquery%2fjquery/-/jquery-1.5.1.tgz'
143
143
  );
144
144
  res();
145
145
  });
@@ -63,7 +63,7 @@ describe('endpoint web unit test', () => {
63
63
  test('should display sidebar info', () => {
64
64
  return new Promise((resolve) => {
65
65
  request(app)
66
- .get('/-/verdaccio/sidebar/@scope/pk1-test')
66
+ .get('/-/verdaccio/data/sidebar/@scope/pk1-test')
67
67
  .expect(HTTP_STATUS.OK)
68
68
  .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
69
69
  .end(function (err, res) {
@@ -85,7 +85,7 @@ describe('endpoint web unit test', () => {
85
85
  test('should display sidebar info by version', () => {
86
86
  return new Promise((resolve) => {
87
87
  request(app)
88
- .get('/-/verdaccio/sidebar/@scope/pk1-test?v=1.0.6')
88
+ .get('/-/verdaccio/data/sidebar/@scope/pk1-test?v=1.0.6')
89
89
  .expect(HTTP_STATUS.OK)
90
90
  .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
91
91
  .end(function (err, res) {
@@ -104,7 +104,7 @@ describe('endpoint web unit test', () => {
104
104
  test('should display sidebar info 404', () => {
105
105
  return new Promise((resolve) => {
106
106
  request(app)
107
- .get('/-/verdaccio/sidebar/@scope/404')
107
+ .get('/-/verdaccio/data/sidebar/@scope/404')
108
108
  .expect(HTTP_STATUS.NOT_FOUND)
109
109
  .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
110
110
  .end(function () {
@@ -116,7 +116,7 @@ describe('endpoint web unit test', () => {
116
116
  test('should display sidebar info 404 with version', () => {
117
117
  return new Promise((resolve) => {
118
118
  request(app)
119
- .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')
120
120
  .expect(HTTP_STATUS.NOT_FOUND)
121
121
  .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
122
122
  .end(function () {
@@ -130,7 +130,7 @@ describe('endpoint web unit test', () => {
130
130
  test('should find @scope/pk1-test', () => {
131
131
  return new Promise((resolve) => {
132
132
  request(app)
133
- .get('/-/verdaccio/search/@scope%2fpk1-test')
133
+ .get('/-/verdaccio/data/search/@scope%2fpk1-test')
134
134
  .expect(HTTP_STATUS.OK)
135
135
  .end(function (_err, res) {
136
136
  expect(res.body).toHaveLength(1);
@@ -142,7 +142,7 @@ describe('endpoint web unit test', () => {
142
142
  test('should not find forbidden-place', () => {
143
143
  return new Promise((resolve) => {
144
144
  request(app)
145
- .get('/-/verdaccio/search/forbidden-place')
145
+ .get('/-/verdaccio/data/search/forbidden-place')
146
146
  .expect(HTTP_STATUS.OK)
147
147
  .end(function (err, res) {
148
148
  // this is expected since we are not logged