From 24d3f50e29643b904ba51d5c6e2ca2b6d6ffba1c Mon Sep 17 00:00:00 2001
From: Dmitry <b4tm4n@mail.ru>
Date: Thu, 7 Oct 2021 13:59:51 +0300
Subject: [PATCH] move config and module api

---
 app/api/config.py | 14 ++++++++++++++
 app/api/module.py | 22 ++++++++++++++++++++++
 pub1c-rest.py     | 32 ++------------------------------
 3 files changed, 38 insertions(+), 30 deletions(-)
 create mode 100644 app/api/config.py
 create mode 100644 app/api/module.py

diff --git a/app/api/config.py b/app/api/config.py
new file mode 100644
index 0000000..910d553
--- /dev/null
+++ b/app/api/config.py
@@ -0,0 +1,14 @@
+from flask_restful import Resource
+
+from app.glob import get_config, get_manager
+
+
+class Config(Resource):
+    def get(self):
+        return get_config()
+
+
+class ConfigTest(Resource):
+    def get(self):
+        manager = get_manager()
+        return manager.check()
\ No newline at end of file
diff --git a/app/api/module.py b/app/api/module.py
new file mode 100644
index 0000000..2b8f071
--- /dev/null
+++ b/app/api/module.py
@@ -0,0 +1,22 @@
+from flask_restful import Resource, abort
+
+from app.glob import get_manager
+
+
+class EnterpriseModule(Resource):
+    def get(self):
+        manager = get_manager()
+        if not manager.has_module():
+            abort(404, message='not found')
+        return {
+            'message': 'found'
+        }
+
+    def put(self):
+        manager = get_manager()
+        if manager.has_module():
+            return '', 304
+        manager.add_module()
+        return {
+            'message': 'success'
+        }
\ No newline at end of file
diff --git a/pub1c-rest.py b/pub1c-rest.py
index 2ccb6bc..4fa2d80 100644
--- a/pub1c-rest.py
+++ b/pub1c-rest.py
@@ -6,8 +6,10 @@ from flask_restful import Resource, Api, reqparse, abort
 from flask_cors import CORS
 
 from app.api.apache_restart import ApacheRestartFlag
+from app.api.config import Config, ConfigTest
 from app.api.index import APIIndex
 from app.api.infobases import InfobasesAvailable, InfobasesAll
+from app.api.module import EnterpriseModule
 from app.glob import get_config, get_manager
 from app.utils import validate_url
 
@@ -26,17 +28,6 @@ remove_parser = reqparse.RequestParser()
 remove_parser.add_argument('force', type=bool, default=False)
 
 
-class Config(Resource):
-    def get(self):
-        return get_config()
-
-
-class ConfigTest(Resource):
-    def get(self):
-        manager = get_manager()
-        return manager.check()
-
-
 class Publications(Resource):
     def get(self) -> List[Dict[str, str]]:
         manager = get_manager()
@@ -113,25 +104,6 @@ class PublicationURL(Resource):
         return {'message': 'success', 'name': name, 'url': url}
 
 
-class EnterpriseModule(Resource):
-    def get(self):
-        manager = get_manager()
-        if not manager.has_module():
-            abort(404, message='not found')
-        return {
-            'message': 'found'
-        }
-
-    def put(self):
-        manager = get_manager()
-        if manager.has_module():
-            return '', 304
-        manager.add_module()
-        return {
-            'message': 'success'
-        }
-
-
 frontend_dir = 'frontend/dist'
 app = Flask(__name__, static_url_path='/', static_folder=frontend_dir, template_folder=frontend_dir)
 api = Api(app, '/api/v1/')