@unito/integration-sdk 2.2.0 → 2.2.2

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.
@@ -944,7 +944,7 @@ function extractSearch(req, res, next) {
944
944
  function extractSelects(req, res, next) {
945
945
  const rawSelect = req.query.select;
946
946
  if (typeof rawSelect === 'string') {
947
- res.locals.selects = rawSelect.split(',');
947
+ res.locals.selects = rawSelect.split(',').map(select => decodeURIComponent(select));
948
948
  }
949
949
  else {
950
950
  res.locals.selects = [];
@@ -1006,7 +1006,7 @@ class Integration {
1006
1006
  * @param options The {@link Options} to configure the Integration instance. Can be used to override the default port.
1007
1007
  */
1008
1008
  constructor(options = {}) {
1009
- this.port = options.port || 9200;
1009
+ this.port = options.port || (process.env.PORT ? parseInt(process.env.PORT, 10) : 9200);
1010
1010
  this.handlers = [];
1011
1011
  }
1012
1012
  /**
@@ -42,7 +42,7 @@ export default class Integration {
42
42
  * @param options The {@link Options} to configure the Integration instance. Can be used to override the default port.
43
43
  */
44
44
  constructor(options = {}) {
45
- this.port = options.port || 9200;
45
+ this.port = options.port || (process.env.PORT ? parseInt(process.env.PORT, 10) : 9200);
46
46
  this.handlers = [];
47
47
  }
48
48
  /**
@@ -1,7 +1,7 @@
1
1
  function extractSelects(req, res, next) {
2
2
  const rawSelect = req.query.select;
3
3
  if (typeof rawSelect === 'string') {
4
- res.locals.selects = rawSelect.split(',');
4
+ res.locals.selects = rawSelect.split(',').map(select => decodeURIComponent(select));
5
5
  }
6
6
  else {
7
7
  res.locals.selects = [];
@@ -3,11 +3,11 @@ import { describe, it } from 'node:test';
3
3
  import extractSelects from '../../src/middlewares/selects.js';
4
4
  describe('selects middleware', () => {
5
5
  it('data', () => {
6
- const request = { query: { select: 'foo,bar.spam,baz' } };
6
+ const request = { query: { select: 'foo,bar.spam,baz,a%23b' } };
7
7
  const response = { locals: {} };
8
8
  extractSelects(request, response, () => { });
9
9
  assert.deepEqual(response.locals, {
10
- selects: ['foo', 'bar.spam', 'baz'],
10
+ selects: ['foo', 'bar.spam', 'baz', 'a#b'],
11
11
  });
12
12
  });
13
13
  it('no data', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-sdk",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Integration SDK",
5
5
  "type": "module",
6
6
  "types": "dist/src/index.d.ts",
@@ -53,7 +53,7 @@ export default class Integration {
53
53
  * @param options The {@link Options} to configure the Integration instance. Can be used to override the default port.
54
54
  */
55
55
  constructor(options: Options = {}) {
56
- this.port = options.port || 9200;
56
+ this.port = options.port || (process.env.PORT ? parseInt(process.env.PORT, 10) : 9200);
57
57
  this.handlers = [];
58
58
  }
59
59
 
@@ -20,7 +20,7 @@ function extractSelects(req: Request, res: Response, next: NextFunction) {
20
20
  const rawSelect = req.query.select;
21
21
 
22
22
  if (typeof rawSelect === 'string') {
23
- res.locals.selects = rawSelect.split(',');
23
+ res.locals.selects = rawSelect.split(',').map(select => decodeURIComponent(select));
24
24
  } else {
25
25
  res.locals.selects = [];
26
26
  }
@@ -5,7 +5,7 @@ import extractSelects from '../../src/middlewares/selects.js';
5
5
 
6
6
  describe('selects middleware', () => {
7
7
  it('data', () => {
8
- const request = { query: { select: 'foo,bar.spam,baz' } } as express.Request<
8
+ const request = { query: { select: 'foo,bar.spam,baz,a%23b' } } as express.Request<
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  any,
11
11
  object,
@@ -17,7 +17,7 @@ describe('selects middleware', () => {
17
17
  extractSelects(request, response, () => {});
18
18
 
19
19
  assert.deepEqual(response.locals, {
20
- selects: ['foo', 'bar.spam', 'baz'],
20
+ selects: ['foo', 'bar.spam', 'baz', 'a#b'],
21
21
  });
22
22
  });
23
23