@xrystal/core 3.26.1 → 3.26.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.26.1",
4
+ "version": "3.26.3",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -20,14 +20,15 @@ export class BaseController {
20
20
  const ctx = store?.ctx || {};
21
21
  const req = store?.req || {};
22
22
  const identityT = (k) => k;
23
- // Önce store içindeki parse edilmiş veriye bak, yoksa orijinaline git
24
23
  const body = store?.metadata?._parsedBody || ctx.body || req.body || ctx.request?.body || {};
25
24
  let query = store?.metadata?._parsedQuery || ctx.query || req.query || ctx.request?.query || {};
26
- const urlStr = ctx.url || req.url || ctx.request?.url || '';
27
- if ((!query || Object.keys(query).length === 0) && typeof urlStr === 'string' && urlStr.includes('?')) {
28
- const parts = urlStr.split('?');
29
- if (parts[1])
30
- query = qs.parse(parts[1]);
25
+ const urlStr = ctx.request?.url || req.url || ctx.url || '';
26
+ if ((!query || Object.keys(query).length === 0) && urlStr && typeof urlStr === 'string') {
27
+ if (urlStr.includes('?')) {
28
+ const queryString = urlStr.split('?')[1];
29
+ if (queryString)
30
+ query = qs.parse(queryString);
31
+ }
31
32
  }
32
33
  const params = {
33
34
  ...(req.params || {}),
@@ -41,7 +42,7 @@ export class BaseController {
41
42
  headers: ctx.headers || req.headers || ctx.request?.headers || {},
42
43
  body,
43
44
  query: query || {},
44
- params,
45
+ params: params || {},
45
46
  lang: ctx.lang || req.lang || 'en',
46
47
  t: ctx.t || req.t || identityT,
47
48
  accounts: ctx.accounts || req.accounts || ctx.user
@@ -112,7 +113,6 @@ export default class Controller extends BaseController {
112
113
  try {
113
114
  const rawReq = store?.req || store?.ctx?.request || store?.ctx?.req;
114
115
  let parsedBody = this.req.body;
115
- let parsedQuery = this.req.query;
116
116
  const contentType = (this.req.headers['content-type'] || '').toLowerCase();
117
117
  const consumeBody = async (bodySource) => {
118
118
  let text = '';
@@ -189,17 +189,21 @@ export default class Controller extends BaseController {
189
189
  if (parsedBody && typeof parsedBody === 'object' && parsedBody.constructor?.name === 'FormData') {
190
190
  parsedBody = Object.fromEntries(parsedBody.entries());
191
191
  }
192
- const finalBody = parsedBody || {};
193
- const finalQuery = parsedQuery || {};
194
- // readonly hatasını önlemek için asıl objeyi değil metadata'yı güncelliyoruz
195
192
  if (store) {
196
193
  if (!store.metadata)
197
194
  store.metadata = { locals: {} };
198
- store.metadata._parsedBody = finalBody;
199
- store.metadata._parsedQuery = finalQuery;
195
+ store.metadata._parsedBody = parsedBody || {};
196
+ store.metadata._parsedQuery = this.req.query;
200
197
  }
201
198
  const currentReq = this.req;
202
- const p = { req: currentReq, res: currentRes, body: currentReq.body, query: currentReq.query, params: currentReq.params, t: currentReq.t, accounts: currentReq.accounts };
199
+ const p = {
200
+ req: currentReq,
201
+ res: currentRes,
202
+ body: currentReq.body,
203
+ queries: currentReq.query,
204
+ params: currentReq.params,
205
+ t: currentReq.t,
206
+ };
203
207
  const extractMeta = (obj) => {
204
208
  if (!obj || typeof obj !== 'object')
205
209
  return;