octalens-mentions 0.0.7 → 0.0.9

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.
@@ -4,19 +4,6 @@ const bootstrap = ({ strapi }) => {
4
4
  const destroy = ({ strapi }) => {
5
5
  };
6
6
  const register = ({ strapi }) => {
7
- strapi.server.use(async (ctx, next) => {
8
- if (ctx.path === "/api/octalens-mentions/ingest" && ctx.method === "POST") {
9
- console.log("=== INGEST REQUEST RECEIVED ===");
10
- console.log("Path:", ctx.path);
11
- console.log("Method:", ctx.method);
12
- console.log("Content-Type:", ctx.request.headers["content-type"]);
13
- if (ctx.request.body) {
14
- console.log("Parsed Body:", JSON.stringify(ctx.request.body, null, 2));
15
- }
16
- console.log("=================================");
17
- }
18
- await next();
19
- });
20
7
  };
21
8
  const config = {
22
9
  default: {},
@@ -92,7 +79,7 @@ const attributes = {
92
79
  type: "string"
93
80
  },
94
81
  viewId: {
95
- type: "string"
82
+ type: "integer"
96
83
  },
97
84
  viewName: {
98
85
  type: "string"
@@ -127,13 +114,8 @@ function getMentionTitle(title, body) {
127
114
  }
128
115
  const controller = ({ strapi }) => ({
129
116
  async ingest(ctx) {
130
- console.log("Raw request body:", JSON.stringify(ctx.request.body, null, 2));
131
- console.log("###############################");
132
- console.log("Raw mention data:", ctx.request.body);
133
- console.log("###############################");
134
117
  const requestBody = ctx.request.body;
135
118
  if (!requestBody?.data) return ctx.badRequest("Missing data in request body");
136
- ctx.body = { data: requestBody?.data };
137
119
  const rawTitle = requestBody.data?.title || "";
138
120
  const rawBody = requestBody.data?.body || "";
139
121
  const generatedTitle = getMentionTitle(rawTitle, rawBody);
@@ -154,13 +136,10 @@ const controller = ({ strapi }) => ({
154
136
  bookmarked: requestBody.data?.bookmarked || false,
155
137
  language: requestBody.data?.language || "",
156
138
  sentimentLabel: requestBody.data?.sentimentLabel || "",
157
- viewId: requestBody.data?.viewId ? String(requestBody.data.viewId) : "",
139
+ viewId: requestBody.data?.viewId || null,
158
140
  viewName: requestBody.data?.viewName || "",
159
141
  subreddit: requestBody.data?.subreddit || ""
160
142
  };
161
- console.log("###############################");
162
- console.log("Parsed mention data:", mentionData);
163
- console.log("###############################");
164
143
  try {
165
144
  const mention2 = await strapi.service("plugin::octalens-mentions.mention").create({
166
145
  data: mentionData
@@ -176,26 +155,7 @@ const controllers = {
176
155
  mention: mention$1,
177
156
  ingest: controller
178
157
  };
179
- const logRawBody = (config2, { strapi }) => {
180
- return async (ctx, next) => {
181
- if (ctx.path === "/api/octalens-mentions/ingest" && ctx.method === "POST") {
182
- const chunks = [];
183
- ctx.req.on("data", (chunk) => {
184
- chunks.push(chunk);
185
- });
186
- ctx.req.on("end", () => {
187
- const rawBody = Buffer.concat(chunks).toString("utf8");
188
- console.log("=== RAW REQUEST BODY ===");
189
- console.log(rawBody);
190
- console.log("=== END RAW REQUEST BODY ===");
191
- });
192
- }
193
- await next();
194
- };
195
- };
196
- const middlewares = {
197
- logRawBody
198
- };
158
+ const middlewares = {};
199
159
  const policies = {};
200
160
  const adminApiRoutes = [
201
161
  {
@@ -3,19 +3,6 @@ const bootstrap = ({ strapi }) => {
3
3
  const destroy = ({ strapi }) => {
4
4
  };
5
5
  const register = ({ strapi }) => {
6
- strapi.server.use(async (ctx, next) => {
7
- if (ctx.path === "/api/octalens-mentions/ingest" && ctx.method === "POST") {
8
- console.log("=== INGEST REQUEST RECEIVED ===");
9
- console.log("Path:", ctx.path);
10
- console.log("Method:", ctx.method);
11
- console.log("Content-Type:", ctx.request.headers["content-type"]);
12
- if (ctx.request.body) {
13
- console.log("Parsed Body:", JSON.stringify(ctx.request.body, null, 2));
14
- }
15
- console.log("=================================");
16
- }
17
- await next();
18
- });
19
6
  };
20
7
  const config = {
21
8
  default: {},
@@ -91,7 +78,7 @@ const attributes = {
91
78
  type: "string"
92
79
  },
93
80
  viewId: {
94
- type: "string"
81
+ type: "integer"
95
82
  },
96
83
  viewName: {
97
84
  type: "string"
@@ -126,13 +113,8 @@ function getMentionTitle(title, body) {
126
113
  }
127
114
  const controller = ({ strapi }) => ({
128
115
  async ingest(ctx) {
129
- console.log("Raw request body:", JSON.stringify(ctx.request.body, null, 2));
130
- console.log("###############################");
131
- console.log("Raw mention data:", ctx.request.body);
132
- console.log("###############################");
133
116
  const requestBody = ctx.request.body;
134
117
  if (!requestBody?.data) return ctx.badRequest("Missing data in request body");
135
- ctx.body = { data: requestBody?.data };
136
118
  const rawTitle = requestBody.data?.title || "";
137
119
  const rawBody = requestBody.data?.body || "";
138
120
  const generatedTitle = getMentionTitle(rawTitle, rawBody);
@@ -153,13 +135,10 @@ const controller = ({ strapi }) => ({
153
135
  bookmarked: requestBody.data?.bookmarked || false,
154
136
  language: requestBody.data?.language || "",
155
137
  sentimentLabel: requestBody.data?.sentimentLabel || "",
156
- viewId: requestBody.data?.viewId ? String(requestBody.data.viewId) : "",
138
+ viewId: requestBody.data?.viewId || null,
157
139
  viewName: requestBody.data?.viewName || "",
158
140
  subreddit: requestBody.data?.subreddit || ""
159
141
  };
160
- console.log("###############################");
161
- console.log("Parsed mention data:", mentionData);
162
- console.log("###############################");
163
142
  try {
164
143
  const mention2 = await strapi.service("plugin::octalens-mentions.mention").create({
165
144
  data: mentionData
@@ -175,26 +154,7 @@ const controllers = {
175
154
  mention: mention$1,
176
155
  ingest: controller
177
156
  };
178
- const logRawBody = (config2, { strapi }) => {
179
- return async (ctx, next) => {
180
- if (ctx.path === "/api/octalens-mentions/ingest" && ctx.method === "POST") {
181
- const chunks = [];
182
- ctx.req.on("data", (chunk) => {
183
- chunks.push(chunk);
184
- });
185
- ctx.req.on("end", () => {
186
- const rawBody = Buffer.concat(chunks).toString("utf8");
187
- console.log("=== RAW REQUEST BODY ===");
188
- console.log(rawBody);
189
- console.log("=== END RAW REQUEST BODY ===");
190
- });
191
- }
192
- await next();
193
- };
194
- };
195
- const middlewares = {
196
- logRawBody
197
- };
157
+ const middlewares = {};
198
158
  const policies = {};
199
159
  const adminApiRoutes = [
200
160
  {
@@ -137,10 +137,6 @@ declare const _default: {
137
137
  };
138
138
  };
139
139
  policies: {};
140
- middlewares: {
141
- logRawBody: (config: any, { strapi }: {
142
- strapi: import("@strapi/types/dist/core").Strapi;
143
- }) => (ctx: any, next: any) => Promise<void>;
144
- };
140
+ middlewares: {};
145
141
  };
146
142
  export default _default;
@@ -1,6 +1,2 @@
1
- declare const _default: {
2
- logRawBody: (config: any, { strapi }: {
3
- strapi: import("@strapi/types/dist/core").Strapi;
4
- }) => (ctx: any, next: any) => Promise<void>;
5
- };
1
+ declare const _default: {};
6
2
  export default _default;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.7",
2
+ "version": "0.0.9",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {
@@ -1,5 +0,0 @@
1
- import type { Core } from '@strapi/strapi';
2
- declare const _default: (config: any, { strapi }: {
3
- strapi: Core.Strapi;
4
- }) => (ctx: any, next: any) => Promise<void>;
5
- export default _default;