Skip to content

Commit 5701639

Browse files
fix: cs & linter
1 parent b03d7b4 commit 5701639

File tree

2 files changed

+26
-38
lines changed

2 files changed

+26
-38
lines changed

src/ActionParameterHandler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { AuthorizationRequiredError } from './error/AuthorizationRequiredError';
1010
import { CurrentUserCheckerNotDefinedError } from './error/CurrentUserCheckerNotDefinedError';
1111
import { isPromiseLike } from './util/isPromiseLike';
1212
import { InvalidParamError } from './error/ParamNormalizationError';
13-
import {ParamType} from "./metadata/types/ParamType";
1413

1514
/**
1615
* Handles action parameter.
@@ -97,7 +96,9 @@ export class ActionParameterHandler<T extends BaseDriver> {
9796
protected async normalizeParamValue(value: any, param: ParamMetadata): Promise<any> {
9897
if (value === null || value === undefined) return value;
9998

100-
const isNormalisationNeeded = typeof value === 'object' && ['queries', 'headers', 'params', 'cookies'].some(paramType => paramType === param.type);
99+
const isNormalisationNeeded =
100+
typeof value === 'object' &&
101+
['queries', 'headers', 'params', 'cookies'].some(paramType => paramType === param.type);
101102
const isTargetPrimitive = ['number', 'string', 'boolean'].indexOf(param.targetName) > -1;
102103
const isTransformationNeeded = (param.parse || param.isTargetObject) && param.type !== 'param';
103104

test/ActionParameterHandler.spec.ts

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,63 @@
1-
import {ActionParameterHandler} from "../src/ActionParameterHandler";
2-
import {
3-
ActionMetadata,
4-
ControllerMetadata,
5-
ExpressDriver,
6-
ParamMetadata,
7-
} from "../src";
8-
import {ActionMetadataArgs} from "../src/metadata/args/ActionMetadataArgs";
9-
import {ControllerMetadataArgs} from "../src/metadata/args/ControllerMetadataArgs";
1+
import { ActionParameterHandler } from '../src/ActionParameterHandler';
2+
import { ActionMetadata, ControllerMetadata, ExpressDriver, ParamMetadata } from '../src';
3+
import { ActionMetadataArgs } from '../src/metadata/args/ActionMetadataArgs';
4+
import { ControllerMetadataArgs } from '../src/metadata/args/ControllerMetadataArgs';
105

11-
const expect = require("chakram").expect;
6+
const expect = require('chakram').expect;
127

13-
describe("ActionParameterHandler", () => {
14-
15-
it("handle", async () => {
8+
describe('ActionParameterHandler', () => {
9+
it('handle', async () => {
1610
const driver = new ExpressDriver();
1711
const actionParameterHandler = new ActionParameterHandler(driver);
1812

1913
const action = {
2014
request: {
2115
params: {
22-
id: "0b5ec98f-e26d-4414-b798-dcd35a5ef859"
16+
id: '0b5ec98f-e26d-4414-b798-dcd35a5ef859',
2317
},
2418
},
25-
response: {}
19+
response: {},
2620
};
2721
const controllerMetadataArgs: ControllerMetadataArgs = {
28-
target: function () {
29-
},
30-
route: "",
31-
type: "json",
22+
target: function () {},
23+
route: '',
24+
type: 'json',
3225
options: {},
3326
};
3427
const controllerMetadata = new ControllerMetadata(controllerMetadataArgs);
3528
const args: ActionMetadataArgs = {
36-
route: "",
37-
method: "getProduct",
29+
route: '',
30+
method: 'getProduct',
3831
options: {},
39-
target: function () {
40-
41-
},
42-
type: "get",
32+
target: function () {},
33+
type: 'get',
4334
appendParams: undefined,
4435
};
4536
const actionMetadata = new ActionMetadata(controllerMetadata, args, {});
4637

4738
const param: ParamMetadata = {
48-
targetName: "product",
39+
targetName: 'product',
4940
isTargetObject: true,
5041
actionMetadata,
51-
target: () => {
52-
},
53-
method: "getProduct",
54-
object: "getProduct",
42+
target: () => {},
43+
method: 'getProduct',
44+
object: 'getProduct',
5545
extraOptions: undefined,
5646
index: 0,
57-
type: "param",
58-
name: "id",
47+
type: 'param',
48+
name: 'id',
5949
parse: undefined,
6050
required: false,
6151
transform: function (action, value) {
6252
return value;
6353
},
6454
classTransform: undefined,
6555
validate: undefined,
66-
targetType: function () {
67-
68-
},
56+
targetType: function () {},
6957
};
7058

7159
const processedValue = await actionParameterHandler.handle(action, param);
7260

7361
expect(processedValue).to.be.eq(action.request.params.id);
7462
});
75-
7663
});

0 commit comments

Comments
 (0)