@xrystal/core 3.16.3 → 3.16.4

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.16.3",
4
+ "version": "3.16.4",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -62,8 +62,15 @@ class Controller {
62
62
  return data;
63
63
  const isBinary = data instanceof Blob || data instanceof Uint8Array || data instanceof ArrayBuffer;
64
64
  const isRaw = store.metadata?._isRaw || isBinary;
65
- const contentType = store.metadata?._contentType || (isBinary ? 'application/octet-stream' : 'application/json');
66
- const body = isRaw ? data : JSON.stringify(data && typeof data === 'object' ? (data.getResponse || data) : data);
65
+ const contentType = store.metadata?._contentType || (isRaw ? 'application/octet-stream' : 'application/json');
66
+ let body;
67
+ if (isRaw || typeof data === 'string') {
68
+ body = data;
69
+ }
70
+ else {
71
+ const rawData = data?.getResponse ? data.getResponse : data;
72
+ body = JSON.stringify(rawData);
73
+ }
67
74
  return new Response(body, {
68
75
  status: store.metadata?._code || 200,
69
76
  headers: { 'content-type': contentType }
@@ -117,9 +124,7 @@ export class ControllerService extends Controller {
117
124
  const resResult = await response({ payload, convertedPayload, logicResult });
118
125
  const successObj = {
119
126
  status: true,
120
- message: Array.isArray(resResult.message)
121
- ? responseMessageHelper.successFully(resResult.message[0], resResult.message[1], currentReq.t)
122
- : resResult.message,
127
+ message: Array.isArray(resResult.message) ? responseMessageHelper.successFully(resResult.message[0], resResult.message[1], currentReq.t) : resResult.message,
123
128
  payload: logicResult?.payload || logicResult
124
129
  };
125
130
  return await this.responseProtocolSwitch({ res: currentRes, resStatus: 200, context: () => new ResponseSchema(successObj).getResponse });