mizozobu 7 лет назад
Родитель
Сommit
aa849fe5f9
3 измененных файлов с 21 добавлено и 18 удалено
  1. 1 1
      lib/routes/admin.js
  2. 7 7
      lib/service/rest-qiita-API.js
  3. 13 10
      lib/util/importer.js

+ 1 - 1
lib/routes/admin.js

@@ -1343,7 +1343,7 @@ module.exports = function (crowi, app) {
    * @param {*} req
    * @param {*} res
    */
-  actions.api.importDataFromQiita = async (req, res) => {
+  actions.api.importDataFromQiita = async(req, res) => {
     try {
       const user = req.user;
       const errors = await importer.importDataFromQiita(user);

+ 7 - 7
lib/service/rest-qiita-API.js

@@ -10,7 +10,7 @@ function getAxios(team, token) {
     },
     responseType: 'json'
   });
-};
+}
 
 /**
  * the service class of restQiitaAPI
@@ -25,7 +25,7 @@ class RestQiitaAPIService {
     this.team = this.config.crowi['importer:qiita:team_name'];
     this.token = this.config.crowi['importer:qiita:access_token'];
     this.axios = getAxios(this.team, this.token);
-  };
+  }
 
   /**
    * get Qiita API
@@ -34,15 +34,15 @@ class RestQiitaAPIService {
    */
   async restAPI(path) {
     return this.axios.get(path)
-      .then(function (res) {
+      .then(function(res) {
         const data = res.data;
         const total = res.headers['total-count'];
         return {
           data,
           total
         };
-      })
-  };
+      });
+  }
 
   /**
    * get Qiita user
@@ -52,7 +52,7 @@ class RestQiitaAPIService {
     const res = await this.restAPI('/users');
     const user = res.data;
     return user;
-  };
+  }
 
   /**
    * get Qiita pages
@@ -63,7 +63,7 @@ class RestQiitaAPIService {
   async getQiitaPages(pageNum, per_page) {
     const res = await this.restAPI(`/items?page=${pageNum}&per_page=${per_page}`);
     return res;
-  };
+  }
 }
 
 module.exports = RestQiitaAPIService;

+ 13 - 10
lib/util/importer.js

@@ -44,7 +44,7 @@ module.exports = crowi => {
       esaClient.api.posts({
         page: pageNum,
         per_page: 100
-      }, async (err, res) => {
+      }, async(err, res) => {
         const nextPage = res.body.next_page;
         const postsReceived = res.body.posts;
 
@@ -67,7 +67,7 @@ module.exports = crowi => {
   /**
    * Import page data from qiita to GROWI
    */
-  importer.importDataFromQiita = async (user) => {
+  importer.importDataFromQiita = async(user) => {
     const firstPage = 1;
     const errors = await importPostsFromQiita(firstPage, user, []);
     return errors;
@@ -80,21 +80,21 @@ module.exports = crowi => {
   const importPostsFromQiita = (pageNum, user, errors) => {
     const per_page = '100';
     return restQiitaAPIService.getQiitaPages(pageNum, per_page)
-      .then(function (res) {
+      .then(function(res) {
         const next = pageNum * per_page + 1;
         const postsReceived = res.data;
         const pageTotal = res.total;
         const data = convertQiitaDataForGrowi(postsReceived, user);
 
         createGrowiPages(data)
-          .then(function (newErrors) {
+          .then(function(newErrors) {
             if (next <= pageTotal) {
               return importPostsFromQiita(next, user, errors.concat(newErrors));
             }
             return errors.concat(newErrors);
           });
       })
-      .catch(function (err) {
+      .catch(function(err) {
         throw new Error(err);
       });
   };
@@ -112,9 +112,11 @@ module.exports = crowi => {
 
       if (category && name) {
         path = `${category}/${name}`;
-      } else if (category) {
+      }
+      else if (category) {
         path = category;
-      } else if (name) {
+      }
+      else if (name) {
         path = name;
       }
 
@@ -150,10 +152,11 @@ module.exports = crowi => {
   /**
    * Import page data from esa to GROWI
    */
-  importer.testConnectionToEsa = async () => {
+  importer.testConnectionToEsa = async() => {
     try {
       await getTeamNameFromEsa();
-    } catch (err) {
+    }
+    catch (err) {
       throw err;
     }
   };
@@ -161,7 +164,7 @@ module.exports = crowi => {
   /**
    * Import page data from qiita to GROWI
    */
-  importer.testConnectionToQiita = async () => {
+  importer.testConnectionToQiita = async() => {
     await restQiitaAPIService.getQiitaUser();
   };