yusuketk 7 лет назад
Родитель
Сommit
4dabdaf39c
1 измененных файлов с 26 добавлено и 0 удалено
  1. 26 0
      src/server/routes/tag.js

+ 26 - 0
src/server/routes/tag.js

@@ -0,0 +1,26 @@
+module.exports = function(crowi, app) {
+  'use strict';
+
+  const Tag = crowi.model('Tag');
+  const ApiResponse = require('../util/apiResponse');
+  const actions = {};
+  const api = {};
+
+  actions.api = api;
+
+
+  /**
+   * @api {get} /tags.search search tags
+   * @apiName searchTag
+   * @apiGroup Tag
+   *
+   * @apiParam {String} q keyword
+   */
+  api.search = async function(req, res) {
+    let tags = await Tag.find({}).select('-_id name');
+    tags = tags.map(tag => tag.name);
+    return res.json(ApiResponse.success({tags}));
+  };
+
+  return actions;
+};