Parcourir la source

test create archive instance

yusuketk il y a 5 ans
Parent
commit
f004d9eabb
2 fichiers modifiés avec 33 ajouts et 0 suppressions
  1. 1 0
      src/server/models/page-archive.js
  2. 32 0
      src/server/routes/apiv3/page.js

+ 1 - 0
src/server/models/page-archive.js

@@ -5,6 +5,7 @@ module.exports = function(crowi) {
   const pageArchiveSchema = new mongoose.Schema({
   const pageArchiveSchema = new mongoose.Schema({
     filePath: { type: String, required: true },
     filePath: { type: String, required: true },
     creator: { type: ObjectId, ref: 'User', index: true },
     creator: { type: ObjectId, ref: 'User', index: true },
+    basePagePath: { type: String, required: true },
   }, {
   }, {
     timestamps: true,
     timestamps: true,
   });
   });

+ 32 - 0
src/server/routes/apiv3/page.js

@@ -182,5 +182,37 @@ module.exports = (crowi) => {
     return res.apiv3({ result });
     return res.apiv3({ result });
   });
   });
 
 
+  /**
+   * @swagger
+   *
+   *    /page/archive:
+   *      post:
+   *        tags: [Page]
+   *        summary: /page/archive
+   *        description: create page archive
+   *        requestBody:
+   *          content:
+   *            application/json:
+   *              schema:
+   *                properties:
+   *                  targetPagePath:
+   *                    type: string
+   *        responses:
+   *          200:
+   *            description: create page archive
+   *            content:
+   *              application/json:
+   *                schema:
+   *                  $ref: '#/components/schemas/Page'
+   */
+  router.post('/archive', accessTokenParser, loginRequired, async(req, res) => {
+    const PageArchive = this.crowi.model('PageArchive');
+    const filePath = 'path';
+    const creator = req.user._id;
+    const basePagePath = '/base';
+    const archive = await PageArchive.create({ filePath, creator, basePagePath });
+    console.log(archive);
+  });
+
   return router;
   return router;
 };
 };