@xrystal/core 3.24.2 → 3.24.3

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.24.2",
4
+ "version": "3.24.3",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -35,7 +35,7 @@ export class BaseController {
35
35
  body,
36
36
  query,
37
37
  params,
38
- lang: ctx.lang || req.lang,
38
+ lang: ctx.lang || req.lang || 'en',
39
39
  t: ctx.t || req.t || identityT,
40
40
  accounts: ctx.accounts || req.accounts || ctx.user
41
41
  };
@@ -94,20 +94,29 @@ export default class Controller extends BaseController {
94
94
  }
95
95
  parseMessage(msg, t, isError = false) {
96
96
  const content = String(msg || (isError ? 'unsuccessful' : 'success_process'));
97
- const parts = content.split(' ');
98
97
  let method = isError ? 'unsuccessful' : 'successfully';
99
- let startIdx = 0;
98
+ let payloadString = content;
100
99
  if (content.startsWith('@')) {
101
- method = parts[0].substring(1);
102
- startIdx = 1;
100
+ const firstSpace = content.indexOf(' ');
101
+ if (firstSpace !== -1) {
102
+ method = content.substring(1, firstSpace);
103
+ payloadString = content.substring(firstSpace + 1);
104
+ }
105
+ else {
106
+ method = content.substring(1);
107
+ payloadString = '';
108
+ }
103
109
  }
104
- const p1Raw = parts[startIdx] || '';
110
+ const params = payloadString.split('-').map(p => p.trim()).filter(p => p !== '');
111
+ const p1Raw = params[0] || '';
105
112
  const p1 = (p1Raw === method || p1Raw === 'unsuccessful' || p1Raw === 'success_process') ? '' : t(p1Raw);
106
- const p2 = parts.slice(startIdx + 1).map(v => t(v)).join(' ');
113
+ const p2 = params.slice(1).map(v => t(v)).join(' ');
107
114
  if (responseMessageHelper[method]) {
108
115
  return responseMessageHelper[method](p1, p2, t);
109
116
  }
110
- return isError ? responseMessageHelper.unsuccessful(p1, p2, t) : responseMessageHelper.successfully(p1, p2, t);
117
+ return isError
118
+ ? responseMessageHelper.unsuccessful(p1, p2, t)
119
+ : responseMessageHelper.successfully(p1, p2, t);
111
120
  }
112
121
  async schema({ checks, logic, response }) {
113
122
  let currentReq = this.req;