nodebb-plugin-integration 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,44 +17,37 @@ exports.init = function (router, middleware) {
17
17
  throw new Error("[Integration] setupAdminPageRoute unavailable");
18
18
  }
19
19
 
20
- // Existing user-facing semantic search.
21
20
  router.post(
22
21
  "/api/v3/integration/search",
23
22
  middleware.ensureLoggedIn,
24
23
  API.apiSearch
25
24
  );
26
25
 
27
- router.get(
28
- "/api/v3/integration/internal/info",
29
- API.internalAuth,
30
- API.internalInfo
31
- );
32
-
33
- router.post(
34
- "/api/v3/integration/internal/post",
35
- API.internalAuth,
36
- API.internalPost
37
- );
38
-
39
- router.post(
40
- "/api/v3/integration/internal/topic",
41
- API.internalAuth,
42
- API.internalTopic
43
- );
44
-
45
- router.post(
46
- "/api/v3/integration/internal/user",
47
- API.internalAuth,
48
- API.internalUser
49
- );
50
-
51
- router.post(
52
- "/api/v3/integration/internal/search",
53
- API.internalAuth,
54
- API.internalSearch
55
- );
26
+ const internal = "/api/v3/integration/internal";
27
+
28
+ router.get(`${internal}/info`, API.internalAuth, API.internalInfo);
29
+
30
+ const routes = {
31
+ post: API.internalPost,
32
+ topic: API.internalTopic,
33
+ user: API.internalUser,
34
+ search: API.internalSearch,
35
+ "topic/create": API.internalCreateTopic,
36
+ "topic/delete": API.internalDeleteTopic,
37
+ "topic/restore": API.internalRestoreTopic,
38
+ topics: API.internalListTopics,
39
+ "post/create": API.internalCreatePost,
40
+ "post/edit": API.internalEditPost,
41
+ "post/delete": API.internalDeletePost,
42
+ "post/restore": API.internalRestorePost,
43
+ "user/delete-posts": API.internalDeleteUserPosts,
44
+ posts: API.internalListPosts
45
+ };
46
+
47
+ for (const [path, handler] of Object.entries(routes)) {
48
+ router.post(`${internal}/${path}`, API.internalAuth, handler);
49
+ }
56
50
 
57
- // Existing ACP page.
58
51
  helpers.setupAdminPageRoute(
59
52
  router,
60
53
  "/admin/plugins/integration",