@verdaccio/server 6.0.0-6-next.39 → 6.0.0-6-next.41
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 +34 -0
- package/build/debug/index.js +0 -3
- package/build/debug/index.js.map +1 -1
- package/build/env.js.map +1 -1
- package/build/index.js +0 -2
- package/build/index.js.map +1 -1
- package/build/server.js +21 -48
- package/build/server.js.map +1 -1
- package/build/utils.js +0 -3
- package/build/utils.js.map +1 -1
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @verdaccio/server
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.41
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@6.0.0-6-next.52
|
|
8
|
+
- @verdaccio/config@6.0.0-6-next.52
|
|
9
|
+
- @verdaccio/api@6.0.0-6-next.35
|
|
10
|
+
- @verdaccio/auth@6.0.0-6-next.31
|
|
11
|
+
- @verdaccio/loaders@6.0.0-6-next.21
|
|
12
|
+
- @verdaccio/logger@6.0.0-6-next.20
|
|
13
|
+
- @verdaccio/middleware@6.0.0-6-next.31
|
|
14
|
+
- verdaccio-audit@11.0.0-6-next.15
|
|
15
|
+
- @verdaccio/store@6.0.0-6-next.32
|
|
16
|
+
- @verdaccio/utils@6.0.0-6-next.20
|
|
17
|
+
- @verdaccio/web@6.0.0-6-next.39
|
|
18
|
+
|
|
19
|
+
## 6.0.0-6-next.40
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [a23628be]
|
|
24
|
+
- Updated dependencies [4b29d715]
|
|
25
|
+
- @verdaccio/web@6.0.0-6-next.38
|
|
26
|
+
- @verdaccio/api@6.0.0-6-next.34
|
|
27
|
+
- @verdaccio/auth@6.0.0-6-next.30
|
|
28
|
+
- @verdaccio/config@6.0.0-6-next.51
|
|
29
|
+
- @verdaccio/core@6.0.0-6-next.51
|
|
30
|
+
- @verdaccio/middleware@6.0.0-6-next.30
|
|
31
|
+
- verdaccio-audit@11.0.0-6-next.14
|
|
32
|
+
- @verdaccio/loaders@6.0.0-6-next.20
|
|
33
|
+
- @verdaccio/store@6.0.0-6-next.31
|
|
34
|
+
- @verdaccio/logger@6.0.0-6-next.19
|
|
35
|
+
- @verdaccio/utils@6.0.0-6-next.19
|
|
36
|
+
|
|
3
37
|
## 6.0.0-6-next.39
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/build/debug/index.js
CHANGED
|
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _default = (app, configPath) => {
|
|
9
8
|
// Hook for tests only
|
|
10
9
|
app.get('/-/_debug', function (req, res, next) {
|
|
11
10
|
if (global.gc) {
|
|
12
11
|
global.gc();
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
next({
|
|
16
14
|
pid: process.pid,
|
|
17
15
|
// @ts-ignore
|
|
@@ -22,6 +20,5 @@ var _default = (app, configPath) => {
|
|
|
22
20
|
});
|
|
23
21
|
});
|
|
24
22
|
};
|
|
25
|
-
|
|
26
23
|
exports.default = _default;
|
|
27
24
|
//# sourceMappingURL=index.js.map
|
package/build/debug/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["app","configPath","get","req","res","next","global","gc","pid","process","main","conf","mem","memoryUsage"],"sources":["../../src/debug/index.ts"],"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.main,\n conf: configPath,\n mem: process.memoryUsage(),\n gc: global.gc,\n });\n }\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["app","configPath","get","req","res","next","global","gc","pid","process","main","conf","mem","memoryUsage"],"sources":["../../src/debug/index.ts"],"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.main,\n conf: configPath,\n mem: process.memoryUsage(),\n gc: global.gc,\n });\n }\n );\n};\n"],"mappings":";;;;;;eAIe,CAACA,GAAgB,EAAEC,UAAmB,KAAW;EAC9D;EACAD,GAAG,CAACE,GAAG,CACL,WAAW,EACX,UAAUC,GAAmB,EAAEC,GAAoB,EAAEC,IAAsB,EAAQ;IACjF,IAAIC,MAAM,CAACC,EAAE,EAAE;MACbD,MAAM,CAACC,EAAE,EAAE;IACb;IAEAF,IAAI,CAAC;MACHG,GAAG,EAAEC,OAAO,CAACD,GAAG;MAChB;MACAE,IAAI,EAAED,OAAO,CAACC,IAAI;MAClBC,IAAI,EAAEV,UAAU;MAChBW,GAAG,EAAEH,OAAO,CAACI,WAAW,EAAE;MAC1BN,EAAE,EAAED,MAAM,CAACC;IACb,CAAC,CAAC;EACJ,CAAC,CACF;AACH,CAAC;AAAA"}
|
package/build/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","names":[],"sources":["../src/env.ts"],"sourcesContent":["// const path = require('path');\n//\n// const APP_ROOT = path.resolve(__dirname, '../../');\n//\n// module.exports = {\n// APP_ROOT,\n// SRC_ROOT: path.resolve(APP_ROOT, 'src/')\n// };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"env.js","names":[],"sources":["../src/env.ts"],"sourcesContent":["// const path = require('path');\n//\n// const APP_ROOT = path.resolve(__dirname, '../../');\n//\n// module.exports = {\n// APP_ROOT,\n// SRC_ROOT: path.resolve(APP_ROOT, 'src/')\n// };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA"}
|
package/build/index.js
CHANGED
|
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
return _server.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
13
12
|
var _server = _interopRequireDefault(require("./server"));
|
|
14
|
-
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
14
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { default } from './server';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { default } from './server';\n"],"mappings":";;;;;;;;;;;AAAA;AAAmC"}
|
package/build/server.js
CHANGED
|
@@ -4,58 +4,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _compression = _interopRequireDefault(require("compression"));
|
|
9
|
-
|
|
10
8
|
var _cors = _interopRequireDefault(require("cors"));
|
|
11
|
-
|
|
12
9
|
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
-
|
|
14
10
|
var _express = _interopRequireDefault(require("express"));
|
|
15
|
-
|
|
16
11
|
var _expressRateLimit = _interopRequireDefault(require("express-rate-limit"));
|
|
17
|
-
|
|
18
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
19
|
-
|
|
20
13
|
var _verdaccioAudit = _interopRequireDefault(require("verdaccio-audit"));
|
|
21
|
-
|
|
22
14
|
var _api = _interopRequireDefault(require("@verdaccio/api"));
|
|
23
|
-
|
|
24
15
|
var _auth = require("@verdaccio/auth");
|
|
25
|
-
|
|
26
16
|
var _config = require("@verdaccio/config");
|
|
27
|
-
|
|
28
17
|
var _core = require("@verdaccio/core");
|
|
29
|
-
|
|
30
18
|
var _loaders = require("@verdaccio/loaders");
|
|
31
|
-
|
|
32
19
|
var _logger = require("@verdaccio/logger");
|
|
33
|
-
|
|
34
20
|
var _middleware = require("@verdaccio/middleware");
|
|
35
|
-
|
|
36
21
|
var _store = require("@verdaccio/store");
|
|
37
|
-
|
|
38
22
|
var _web = _interopRequireDefault(require("@verdaccio/web"));
|
|
39
|
-
|
|
40
23
|
var _debug2 = _interopRequireDefault(require("./debug"));
|
|
41
|
-
|
|
42
24
|
var _utils = require("./utils");
|
|
43
|
-
|
|
44
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
|
-
|
|
46
26
|
const debug = (0, _debug.default)('verdaccio:server');
|
|
47
|
-
|
|
48
27
|
const defineAPI = async function (config, storage) {
|
|
49
28
|
const auth = new _auth.Auth(config);
|
|
50
29
|
await auth.init();
|
|
51
30
|
const app = (0, _express.default)();
|
|
52
|
-
const limiter = new _expressRateLimit.default(config.serverSettings.rateLimit);
|
|
31
|
+
const limiter = new _expressRateLimit.default(config.serverSettings.rateLimit);
|
|
32
|
+
// run in production mode by default, just in case
|
|
53
33
|
// it shouldn't make any difference anyway
|
|
54
|
-
|
|
55
34
|
app.set('env', process.env.NODE_ENV || 'production');
|
|
56
35
|
app.use((0, _cors.default)());
|
|
57
|
-
app.use(limiter);
|
|
36
|
+
app.use(limiter);
|
|
58
37
|
|
|
38
|
+
// Router setup
|
|
59
39
|
app.use(_middleware.log);
|
|
60
40
|
app.use(_middleware.errorReportingMiddleware);
|
|
61
41
|
app.use(function (req, res, next) {
|
|
@@ -66,23 +46,21 @@ const defineAPI = async function (config, storage) {
|
|
|
66
46
|
app.get('/favicon.ico', function (req, res, next) {
|
|
67
47
|
req.url = '/-/static/favicon.png';
|
|
68
48
|
next();
|
|
69
|
-
});
|
|
49
|
+
});
|
|
70
50
|
|
|
51
|
+
// Hook for tests only
|
|
71
52
|
if (config._debug) {
|
|
72
53
|
(0, _debug2.default)(app, config.configPath);
|
|
73
54
|
}
|
|
74
|
-
|
|
75
55
|
const plugins = await (0, _loaders.asyncLoadPlugin)(config.middlewares, {
|
|
76
56
|
config,
|
|
77
57
|
logger: _logger.logger
|
|
78
58
|
}, function (plugin) {
|
|
79
59
|
return typeof plugin.register_middlewares !== 'undefined';
|
|
80
60
|
});
|
|
81
|
-
|
|
82
61
|
if (plugins.length === 0) {
|
|
83
|
-
_logger.logger.info('none middleware plugins has been defined, adding audit middleware by default');
|
|
84
|
-
|
|
85
|
-
|
|
62
|
+
_logger.logger.info('none middleware plugins has been defined, adding audit middleware by default');
|
|
63
|
+
// @ts-ignore
|
|
86
64
|
plugins.push(new _verdaccioAudit.default({
|
|
87
65
|
enabled: true,
|
|
88
66
|
strict_ssl: true
|
|
@@ -91,23 +69,24 @@ const defineAPI = async function (config, storage) {
|
|
|
91
69
|
logger: _logger.logger
|
|
92
70
|
}));
|
|
93
71
|
}
|
|
94
|
-
|
|
95
72
|
plugins.forEach(plugin => {
|
|
96
73
|
plugin.register_middlewares(app, auth, storage);
|
|
97
|
-
});
|
|
98
|
-
// @ts-ignore
|
|
74
|
+
});
|
|
99
75
|
|
|
100
|
-
|
|
76
|
+
// For npm request
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
app.use((0, _api.default)(config, auth, storage));
|
|
101
79
|
|
|
80
|
+
// For WebUI & WebUI API
|
|
102
81
|
if (_lodash.default.get(config, 'web.enable', true)) {
|
|
103
82
|
app.use(await (0, _web.default)(config, auth, storage));
|
|
104
83
|
} else {
|
|
105
84
|
app.get('/', function (req, res, next) {
|
|
106
85
|
next(_core.errorUtils.getNotFound(_core.API_ERROR.WEB_DISABLED));
|
|
107
86
|
});
|
|
108
|
-
}
|
|
109
|
-
|
|
87
|
+
}
|
|
110
88
|
|
|
89
|
+
// Catch 404
|
|
111
90
|
app.get('/*', function (req, res, next) {
|
|
112
91
|
next(_core.errorUtils.getNotFound('resource not found'));
|
|
113
92
|
});
|
|
@@ -116,13 +95,11 @@ const defineAPI = async function (config, storage) {
|
|
|
116
95
|
if (err.code === 'ECONNABORT' && res.statusCode === _core.HTTP_STATUS.NOT_MODIFIED) {
|
|
117
96
|
return next();
|
|
118
97
|
}
|
|
119
|
-
|
|
120
98
|
if (_lodash.default.isFunction(res.locals.report_error) === false) {
|
|
121
99
|
// in case of very early error this middleware may not be loaded before error is generated
|
|
122
100
|
// fixing that
|
|
123
101
|
(0, _middleware.errorReportingMiddleware)(req, res, _lodash.default.noop);
|
|
124
102
|
}
|
|
125
|
-
|
|
126
103
|
res.locals.report_error(err);
|
|
127
104
|
} else {
|
|
128
105
|
// Fall to Middleware.final
|
|
@@ -132,16 +109,15 @@ const defineAPI = async function (config, storage) {
|
|
|
132
109
|
app.use(_middleware.final);
|
|
133
110
|
return app;
|
|
134
111
|
};
|
|
135
|
-
|
|
136
112
|
var startServer = async function startServer(configHash) {
|
|
137
113
|
debug('start server');
|
|
138
|
-
const config = new _config.Config({
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
114
|
+
const config = new _config.Config({
|
|
115
|
+
...configHash
|
|
116
|
+
});
|
|
117
|
+
// register middleware plugins
|
|
118
|
+
debug('loaded filter plugin');
|
|
119
|
+
// @ts-ignore
|
|
143
120
|
const storage = new _store.Storage(config);
|
|
144
|
-
|
|
145
121
|
try {
|
|
146
122
|
// waits until init calls have been initialized
|
|
147
123
|
debug('storage init start');
|
|
@@ -151,12 +127,9 @@ var startServer = async function startServer(configHash) {
|
|
|
151
127
|
_logger.logger.error({
|
|
152
128
|
error: err.msg
|
|
153
129
|
}, 'storage has failed: @{error}');
|
|
154
|
-
|
|
155
130
|
throw new Error(err);
|
|
156
131
|
}
|
|
157
|
-
|
|
158
132
|
return await defineAPI(config, storage);
|
|
159
133
|
};
|
|
160
|
-
|
|
161
134
|
exports.default = startServer;
|
|
162
135
|
//# sourceMappingURL=server.js.map
|
package/build/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["debug","buildDebug","defineAPI","config","storage","auth","Auth","init","app","express","limiter","RateLimit","serverSettings","rateLimit","set","process","env","NODE_ENV","use","cors","log","errorReportingMiddleware","req","res","next","setHeader","getUserAgent","user_agent","compression","get","url","_debug","hookDebug","configPath","plugins","asyncLoadPlugin","middlewares","logger","plugin","register_middlewares","length","info","push","AuditMiddleware","enabled","strict_ssl","forEach","apiEndpoint","_","webMiddleware","errorUtils","getNotFound","API_ERROR","WEB_DISABLED","err","isError","code","statusCode","HTTP_STATUS","NOT_MODIFIED","isFunction","locals","report_error","noop","final","startServer","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 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 } 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 } 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';\nimport { getUserAgent } from './utils';\n\nconst debug = buildDebug('verdaccio:server');\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 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', getUserAgent(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.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(await 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('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 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 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":"
|
|
1
|
+
{"version":3,"file":"server.js","names":["debug","buildDebug","defineAPI","config","storage","auth","Auth","init","app","express","limiter","RateLimit","serverSettings","rateLimit","set","process","env","NODE_ENV","use","cors","log","errorReportingMiddleware","req","res","next","setHeader","getUserAgent","user_agent","compression","get","url","_debug","hookDebug","configPath","plugins","asyncLoadPlugin","middlewares","logger","plugin","register_middlewares","length","info","push","AuditMiddleware","enabled","strict_ssl","forEach","apiEndpoint","_","webMiddleware","errorUtils","getNotFound","API_ERROR","WEB_DISABLED","err","isError","code","statusCode","HTTP_STATUS","NOT_MODIFIED","isFunction","locals","report_error","noop","final","startServer","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 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 } 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 } 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';\nimport { getUserAgent } from './utils';\n\nconst debug = buildDebug('verdaccio:server');\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 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', getUserAgent(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.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(await 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('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 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 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;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAGA;AACA;AAAuC;AAEvC,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,kBAAkB,CAAC;AAE5C,MAAMC,SAAS,GAAG,gBAAgBC,MAAe,EAAEC,OAAgB,EAAgB;EACjF,MAAMC,IAAU,G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AG,CAAC;EACtB;EACA,OAAO,MAAMpD,SAAS,CAACC,MAAM,EAAEC,OAAO,CAAC;AACzC,CAAC;AAAA"}
|
package/build/utils.js
CHANGED
|
@@ -4,16 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getUserAgent = getUserAgent;
|
|
7
|
-
|
|
8
7
|
const pkgVersion = require('../package.json').version;
|
|
9
|
-
|
|
10
8
|
function getUserAgent(userAgent) {
|
|
11
9
|
if (typeof userAgent === 'string') {
|
|
12
10
|
return userAgent;
|
|
13
11
|
} else if (userAgent === false) {
|
|
14
12
|
return 'hidden';
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
return `verdaccio/${pkgVersion}`;
|
|
18
15
|
}
|
|
19
16
|
//# sourceMappingURL=utils.js.map
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["pkgVersion","require","version","getUserAgent","userAgent"],"sources":["../src/utils.ts"],"sourcesContent":["const pkgVersion = require('../package.json').version;\n\nexport function getUserAgent(userAgent: string): string {\n if (typeof userAgent === 'string') {\n return userAgent;\n } else if (userAgent === false) {\n return 'hidden';\n }\n\n return `verdaccio/${pkgVersion}`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["pkgVersion","require","version","getUserAgent","userAgent"],"sources":["../src/utils.ts"],"sourcesContent":["const pkgVersion = require('../package.json').version;\n\nexport function getUserAgent(userAgent: string): string {\n if (typeof userAgent === 'string') {\n return userAgent;\n } else if (userAgent === false) {\n return 'hidden';\n }\n\n return `verdaccio/${pkgVersion}`;\n}\n"],"mappings":";;;;;;AAAA,MAAMA,UAAU,GAAGC,OAAO,CAAC,iBAAiB,CAAC,CAACC,OAAO;AAE9C,SAASC,YAAY,CAACC,SAAiB,EAAU;EACtD,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IACjC,OAAOA,SAAS;EAClB,CAAC,MAAM,IAAIA,SAAS,KAAK,KAAK,EAAE;IAC9B,OAAO,QAAQ;EACjB;EAEA,OAAQ,aAAYJ,UAAW,EAAC;AAClC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/server",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.41",
|
|
4
4
|
"description": "server logic",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"npm": ">=6"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@verdaccio/api": "6.0.0-6-next.
|
|
34
|
-
"@verdaccio/auth": "6.0.0-6-next.
|
|
35
|
-
"@verdaccio/core": "6.0.0-6-next.
|
|
36
|
-
"@verdaccio/config": "6.0.0-6-next.
|
|
37
|
-
"@verdaccio/loaders": "6.0.0-6-next.
|
|
38
|
-
"@verdaccio/logger": "6.0.0-6-next.
|
|
39
|
-
"@verdaccio/middleware": "6.0.0-6-next.
|
|
40
|
-
"@verdaccio/store": "6.0.0-6-next.
|
|
41
|
-
"@verdaccio/utils": "6.0.0-6-next.
|
|
42
|
-
"@verdaccio/web": "6.0.0-6-next.
|
|
43
|
-
"verdaccio-audit": "11.0.0-6-next.
|
|
33
|
+
"@verdaccio/api": "6.0.0-6-next.35",
|
|
34
|
+
"@verdaccio/auth": "6.0.0-6-next.31",
|
|
35
|
+
"@verdaccio/core": "6.0.0-6-next.52",
|
|
36
|
+
"@verdaccio/config": "6.0.0-6-next.52",
|
|
37
|
+
"@verdaccio/loaders": "6.0.0-6-next.21",
|
|
38
|
+
"@verdaccio/logger": "6.0.0-6-next.20",
|
|
39
|
+
"@verdaccio/middleware": "6.0.0-6-next.31",
|
|
40
|
+
"@verdaccio/store": "6.0.0-6-next.32",
|
|
41
|
+
"@verdaccio/utils": "6.0.0-6-next.20",
|
|
42
|
+
"@verdaccio/web": "6.0.0-6-next.39",
|
|
43
|
+
"verdaccio-audit": "11.0.0-6-next.15",
|
|
44
44
|
"compression": "1.7.4",
|
|
45
45
|
"cors": "2.8.5",
|
|
46
46
|
"debug": "4.3.4",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"lodash": "4.17.21"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/node": "16.
|
|
53
|
-
"@verdaccio/proxy": "6.0.0-6-next.
|
|
52
|
+
"@types/node": "16.18.3",
|
|
53
|
+
"@verdaccio/proxy": "6.0.0-6-next.30",
|
|
54
54
|
"@verdaccio/test-helper": "2.0.0-6-next.6",
|
|
55
55
|
"http-errors": "1.8.1"
|
|
56
56
|
},
|