From 67c31b69cac11436a5dcbc5961748eaab0bae99b Mon Sep 17 00:00:00 2001
From: Robert Sabirov <rob.sabirov@yandex.ru>
Date: Fri, 19 Jun 2020 08:40:06 +0300
Subject: [PATCH] fix: move bodyParse to the upper level (#1841)

Co-authored-by: Juan Picado <juanpicado19@gmail.com>
---
 src/api/endpoint/index.ts | 2 --
 src/api/index.ts          | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/api/endpoint/index.ts b/src/api/endpoint/index.ts
index c651b5cd4..61481a71b 100644
--- a/src/api/endpoint/index.ts
+++ b/src/api/endpoint/index.ts
@@ -3,7 +3,6 @@ import { Config } from '@verdaccio/types';
 import _ from 'lodash';
 
 import express from 'express';
-import bodyParser from 'body-parser';
 import whoami from './api/whoami';
 import ping from './api/ping';
 import user from './api/user';
@@ -42,7 +41,6 @@ export default function(config: Config, auth: IAuth, storage: IStorageHandler) {
   app.param('anything', match(/.*/));
 
   app.use(auth.apiJWTmiddleware());
-  app.use(bodyParser.json({ strict: false, limit: config.max_body_size || '10mb' }));
   app.use(antiLoop(config));
   // encode / in a scoped package name to be matched as a single parameter in routes
   app.use(encodeScopePackage);
diff --git a/src/api/index.ts b/src/api/index.ts
index fd802f30d..d90c4ca6b 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,5 +1,6 @@
 import _ from 'lodash';
 import express, { Application } from 'express';
+import bodyParser from 'body-parser';
 import compression from 'compression';
 import cors from 'cors';
 import { HttpError } from 'http-errors';
@@ -46,6 +47,8 @@ const defineAPI = function(config: IConfig, storage: IStorageHandler): any {
     hookDebug(app, config.self_path);
   }
 
+  app.use(bodyParser.json({ strict: false, limit: config.max_body_size || '10mb' }));
+
   // register middleware plugins
   const plugin_params = {
     config: config,