Yuki Takei 6 лет назад
Родитель
Сommit
a511f85843

+ 1 - 2
src/client/js/components/Admin/ImportData/GrowiZipUploadForm.jsx

@@ -31,8 +31,7 @@ class GrowiZipUploadForm extends React.Component {
     formData.append('_csrf', this.props.appContainer.csrfToken);
     formData.append('file', this.inputRef.current.files[0]);
 
-    // TODO: use appContainer.apiv3.post
-    const { data } = await this.props.appContainer.apiPost('/v3/import/upload', formData);
+    const { data } = await this.props.appContainer.apiv3Post('/import/upload', formData);
     this.props.onUpload(data);
     // TODO: toastSuccess, toastError
   }

+ 11 - 17
src/server/routes/apiv3/import.js

@@ -26,11 +26,9 @@ const router = express.Router();
  *      ImportStatus:
  *        type: object
  *        properties:
- *          zipFileStats:
- *            type: array
- *            items:
- *              type: object
- *              description: the property of each file
+ *          zipFileStat:
+ *            type: object
+ *            description: the property object
  *          progressList:
  *            type: array
  *            items:
@@ -127,13 +125,13 @@ module.exports = (crowi) => {
    *                    $ref: '#/components/schemas/ImportStatus'
    */
   router.get('/status', accessTokenParser, loginRequired, adminRequired, async(req, res) => {
-    const status = await importService.getStatus();
-
-    // TODO: use res.apiv3
-    return res.json({
-      ok: true,
-      status,
-    });
+    try {
+      const status = await importService.getStatus();
+      return res.apiv3(status);
+    }
+    catch (err) {
+      return res.apiv3Err(err, 500);
+    }
   });
 
   /**
@@ -242,11 +240,7 @@ module.exports = (crowi) => {
       // validate with meta.json
       importService.validate(data.meta);
 
-      // TODO: use res.apiv3
-      return res.send({
-        ok: true,
-        data,
-      });
+      return res.apiv3(data);
     }
     catch (err) {
       // TODO: use ApiV3Error