@verdaccio/server 6.0.0-6-next.37 → 6.0.0-6-next.39

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,39 @@
1
1
  # @verdaccio/server
2
2
 
3
+ ## 6.0.0-6-next.39
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [b4cc8001]
8
+ - @verdaccio/api@6.0.0-6-next.33
9
+ - @verdaccio/web@6.0.0-6-next.37
10
+ - @verdaccio/core@6.0.0-6-next.50
11
+ - @verdaccio/config@6.0.0-6-next.50
12
+ - @verdaccio/auth@6.0.0-6-next.29
13
+ - @verdaccio/loaders@6.0.0-6-next.19
14
+ - @verdaccio/logger@6.0.0-6-next.18
15
+ - @verdaccio/middleware@6.0.0-6-next.29
16
+ - verdaccio-audit@11.0.0-6-next.13
17
+ - @verdaccio/store@6.0.0-6-next.30
18
+ - @verdaccio/utils@6.0.0-6-next.18
19
+
20
+ ## 6.0.0-6-next.38
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [ce013d2f]
25
+ - @verdaccio/api@6.0.0-6-next.32
26
+ - @verdaccio/store@6.0.0-6-next.29
27
+ - @verdaccio/web@6.0.0-6-next.36
28
+ - @verdaccio/core@6.0.0-6-next.49
29
+ - @verdaccio/config@6.0.0-6-next.49
30
+ - @verdaccio/auth@6.0.0-6-next.28
31
+ - @verdaccio/loaders@6.0.0-6-next.18
32
+ - @verdaccio/logger@6.0.0-6-next.17
33
+ - @verdaccio/middleware@6.0.0-6-next.28
34
+ - verdaccio-audit@11.0.0-6-next.12
35
+ - @verdaccio/utils@6.0.0-6-next.17
36
+
3
37
  ## 6.0.0-6-next.37
4
38
 
5
39
  ### Major Changes
package/build/server.d.ts CHANGED
@@ -1,9 +1,3 @@
1
- import { IBasicAuth } from '@verdaccio/auth';
2
- import { Storage } from '@verdaccio/store';
3
1
  import { ConfigYaml } from '@verdaccio/types';
4
- import { IPlugin } from '@verdaccio/types';
5
- export interface IPluginMiddleware<T> extends IPlugin<T> {
6
- register_middlewares(app: any, auth: IBasicAuth<T>, storage: Storage): void;
7
- }
8
2
  declare const _default: (configHash: ConfigYaml) => Promise<any>;
9
3
  export default _default;
package/build/server.js CHANGED
@@ -76,13 +76,14 @@ const defineAPI = async function (config, storage) {
76
76
  config,
77
77
  logger: _logger.logger
78
78
  }, function (plugin) {
79
- return plugin.register_middlewares;
79
+ return typeof plugin.register_middlewares !== 'undefined';
80
80
  });
81
81
 
82
82
  if (plugins.length === 0) {
83
- _logger.logger.info('none middleware plugins has been defined, adding audit middleware by default');
83
+ _logger.logger.info('none middleware plugins has been defined, adding audit middleware by default'); // @ts-ignore
84
84
 
85
- plugins.push(new _verdaccioAudit.default({ ...config,
85
+
86
+ plugins.push(new _verdaccioAudit.default({
86
87
  enabled: true,
87
88
  strict_ssl: true
88
89
  }, {
@@ -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, { 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 { 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, IPlugin } 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\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 = async function (config: IConfig, storage: Storage): Promise<any> {\n const auth: Auth = new Auth(config);\n await auth.init();\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', 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: IPluginMiddleware<IConfig>[] = await asyncLoadPlugin(\n config.middlewares,\n {\n config,\n logger,\n },\n function (plugin: IPluginMiddleware<IConfig>) {\n return plugin.register_middlewares;\n }\n );\n\n if (plugins.length === 0) {\n logger.info('none middleware plugins has been defined, adding audit middleware by default');\n plugins.push(\n new AuditMiddleware({ ...config, enabled: true, strict_ssl: true }, { config, logger })\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(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;;;;AAMA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,kBAAX,CAAd;;AAEA,MAAMC,S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AEA,KAAK,EAAEf,GAAG,CAACgB;IAAb,CAAb,EAAiC,8BAAjC;;IACA,MAAM,IAAIC,KAAJ,CAAUjB,GAAV,CAAN;EACD;;EACD,OAAO,MAAMpD,SAAS,CAACC,MAAD,EAASC,OAAT,CAAtB;AACD,C"}
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;;;;AAEA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,kBAAX,CAAd;;AAEA,MAAMC,SAAS,GAAG,gBAAgBC,MAAhB,EAAiCC,OAAjC,EAAiE;EACjF,MAAMC,IAAU,GAAG,IAAIC,UAAJ,CAASH,MAAT,CAAnB;EACA,MAAME,IAAI,CAACE,IAAL,EAAN;EACA,MAAMC,GAAG,GAAG,IAAAC,gBAAA,GAAZ;EACA,MAAMC,OAAO,GAAG,IAAIC,yBAAJ,CAAcR,MAAM,CAACS,cAAP,CAAsBC,SAApC,CAAhB,CAJiF,CAKjF;EACA;;EACAL,GAAG,CAACM,GAAJ,CAAQ,KAAR,EAAeC,OAAO,CAACC,GAAR,CAAYC,QAAZ,IAAwB,YAAvC;EACAT,GAAG,CAACU,GAAJ,CAAQ,IAAAC,aAAA,GAAR;EACAX,GAAG,CAACU,GAAJ,CAAQR,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,GAAzB,EAA8BC,GAA9B,EAAmCyB,eAAA,CAAEe,IAArC;MACD;;MACDxC,GAAG,CAACsC,MAAJ,CAAWC,YAAX,CAAwBR,GAAxB;IACD,CAVD,MAUO;MACL;MACA,OAAO9B,IAAI,CAAC8B,GAAD,CAAX;IACD;EACF,CApBD;EAsBA9C,GAAG,CAACU,GAAJ,CAAQ8C,iBAAR;EAEA,OAAOxD,GAAP;AACD,CAlGD;;IAoG+ByD,W,GAAf,eAAeA,WAAf,CAA2BC,UAA3B,EAAiE;EAC/ElE,KAAK,CAAC,cAAD,CAAL;EACA,MAAMG,MAAe,GAAG,IAAIgE,cAAJ,CAAc,EAAE,GAAGD;EAAL,CAAd,CAAxB,CAF+E,CAG/E;;EACAlE,KAAK,CAAC,sBAAD,CAAL,CAJ+E,CAK/E;;EACA,MAAMI,OAAgB,GAAG,IAAIgE,cAAJ,CAAYjE,MAAZ,CAAzB;;EACA,IAAI;IACF;IACAH,KAAK,CAAC,oBAAD,CAAL;IACA,MAAMI,OAAO,CAACG,IAAR,CAAaJ,MAAb,CAAN;IACAH,KAAK,CAAC,kBAAD,CAAL;EACD,CALD,CAKE,OAAOsD,GAAP,EAAiB;IACjBjB,cAAA,CAAOgC,KAAP,CAAa;MAAEA,KAAK,EAAEf,GAAG,CAACgB;IAAb,CAAb,EAAiC,8BAAjC;;IACA,MAAM,IAAIC,KAAJ,CAAUjB,GAAV,CAAN;EACD;;EACD,OAAO,MAAMpD,SAAS,CAACC,MAAD,EAASC,OAAT,CAAtB;AACD,C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/server",
3
- "version": "6.0.0-6-next.37",
3
+ "version": "6.0.0-6-next.39",
4
4
  "description": "server logic",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -30,28 +30,28 @@
30
30
  "npm": ">=6"
31
31
  },
32
32
  "dependencies": {
33
- "@verdaccio/api": "6.0.0-6-next.31",
34
- "@verdaccio/auth": "6.0.0-6-next.27",
35
- "@verdaccio/core": "6.0.0-6-next.48",
36
- "@verdaccio/config": "6.0.0-6-next.48",
37
- "@verdaccio/loaders": "6.0.0-6-next.17",
38
- "@verdaccio/logger": "6.0.0-6-next.16",
39
- "@verdaccio/middleware": "6.0.0-6-next.27",
40
- "@verdaccio/store": "6.0.0-6-next.28",
41
- "@verdaccio/utils": "6.0.0-6-next.16",
42
- "@verdaccio/web": "6.0.0-6-next.35",
43
- "verdaccio-audit": "11.0.0-6-next.11",
33
+ "@verdaccio/api": "6.0.0-6-next.33",
34
+ "@verdaccio/auth": "6.0.0-6-next.29",
35
+ "@verdaccio/core": "6.0.0-6-next.50",
36
+ "@verdaccio/config": "6.0.0-6-next.50",
37
+ "@verdaccio/loaders": "6.0.0-6-next.19",
38
+ "@verdaccio/logger": "6.0.0-6-next.18",
39
+ "@verdaccio/middleware": "6.0.0-6-next.29",
40
+ "@verdaccio/store": "6.0.0-6-next.30",
41
+ "@verdaccio/utils": "6.0.0-6-next.18",
42
+ "@verdaccio/web": "6.0.0-6-next.37",
43
+ "verdaccio-audit": "11.0.0-6-next.13",
44
44
  "compression": "1.7.4",
45
45
  "cors": "2.8.5",
46
46
  "debug": "4.3.4",
47
- "express": "4.18.1",
47
+ "express": "4.18.2",
48
48
  "express-rate-limit": "5.5.1",
49
49
  "lodash": "4.17.21"
50
50
  },
51
51
  "devDependencies": {
52
- "@types/node": "16.11.60",
53
- "@verdaccio/proxy": "6.0.0-6-next.26",
54
- "@verdaccio/test-helper": "2.0.0-6-next.5",
52
+ "@types/node": "16.11.65",
53
+ "@verdaccio/proxy": "6.0.0-6-next.28",
54
+ "@verdaccio/test-helper": "2.0.0-6-next.6",
55
55
  "http-errors": "1.8.1"
56
56
  },
57
57
  "funding": {
package/src/server.ts CHANGED
@@ -1,38 +1,34 @@
1
1
  import compression from 'compression';
2
2
  import cors from 'cors';
3
3
  import buildDebug from 'debug';
4
- import express, { Application } from 'express';
4
+ import express from 'express';
5
5
  import RateLimit from 'express-rate-limit';
6
6
  import { HttpError } from 'http-errors';
7
7
  import _ from 'lodash';
8
8
  import AuditMiddleware from 'verdaccio-audit';
9
9
 
10
10
  import apiEndpoint from '@verdaccio/api';
11
- import { Auth, IBasicAuth } from '@verdaccio/auth';
11
+ import { Auth } from '@verdaccio/auth';
12
12
  import { Config as AppConfig } from '@verdaccio/config';
13
- import { API_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';
13
+ import { API_ERROR, HTTP_STATUS, errorUtils, pluginUtils } from '@verdaccio/core';
14
14
  import { asyncLoadPlugin } from '@verdaccio/loaders';
15
15
  import { logger } from '@verdaccio/logger';
16
16
  import { errorReportingMiddleware, final, log } from '@verdaccio/middleware';
17
17
  import { Storage } from '@verdaccio/store';
18
18
  import { ConfigYaml } from '@verdaccio/types';
19
- import { Config as IConfig, IPlugin } from '@verdaccio/types';
19
+ import { Config as IConfig } from '@verdaccio/types';
20
20
  import webMiddleware from '@verdaccio/web';
21
21
 
22
22
  import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
23
23
  import hookDebug from './debug';
24
24
  import { getUserAgent } from './utils';
25
25
 
26
- export interface IPluginMiddleware<T> extends IPlugin<T> {
27
- register_middlewares(app: any, auth: IBasicAuth<T>, storage: Storage): void;
28
- }
29
-
30
26
  const debug = buildDebug('verdaccio:server');
31
27
 
32
28
  const defineAPI = async function (config: IConfig, storage: Storage): Promise<any> {
33
29
  const auth: Auth = new Auth(config);
34
30
  await auth.init();
35
- const app: Application = express();
31
+ const app = express();
36
32
  const limiter = new RateLimit(config.serverSettings.rateLimit);
37
33
  // run in production mode by default, just in case
38
34
  // it shouldn't make any difference anyway
@@ -63,25 +59,24 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise<an
63
59
  hookDebug(app, config.configPath);
64
60
  }
65
61
 
66
- const plugins: IPluginMiddleware<IConfig>[] = await asyncLoadPlugin(
62
+ const plugins: pluginUtils.ExpressMiddleware<IConfig, {}, Auth>[] = await asyncLoadPlugin(
67
63
  config.middlewares,
68
64
  {
69
65
  config,
70
66
  logger,
71
67
  },
72
- function (plugin: IPluginMiddleware<IConfig>) {
73
- return plugin.register_middlewares;
68
+ function (plugin) {
69
+ return typeof plugin.register_middlewares !== 'undefined';
74
70
  }
75
71
  );
76
72
 
77
73
  if (plugins.length === 0) {
78
74
  logger.info('none middleware plugins has been defined, adding audit middleware by default');
79
- plugins.push(
80
- new AuditMiddleware({ ...config, enabled: true, strict_ssl: true }, { config, logger })
81
- );
75
+ // @ts-ignore
76
+ plugins.push(new AuditMiddleware({ enabled: true, strict_ssl: true }, { config, logger }));
82
77
  }
83
78
 
84
- plugins.forEach((plugin: IPluginMiddleware<IConfig>) => {
79
+ plugins.forEach((plugin: pluginUtils.ExpressMiddleware<IConfig, {}, Auth>) => {
85
80
  plugin.register_middlewares(app, auth, storage);
86
81
  });
87
82
 
package/tsconfig.json CHANGED
@@ -16,9 +16,6 @@
16
16
  {
17
17
  "path": "../../config"
18
18
  },
19
- {
20
- "path": "../../core/commons-api"
21
- },
22
19
  {
23
20
  "path": "../../loaders"
24
21
  },
@@ -28,9 +25,6 @@
28
25
  {
29
26
  "path": "../../middleware"
30
27
  },
31
- {
32
- "path": "../../mock"
33
- },
34
28
  {
35
29
  "path": "../../plugins/audit"
36
30
  },