Skip to content

Commit ac1b1f0

Browse files
committed
chore: change prettier rule
1 parent b0158af commit ac1b1f0

40 files changed

+416
-412
lines changed

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

lib/builders/http-request.builder.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { type PathVariableBuilder } from "./path-variable.builder";
2-
import { PayloadBuilder } from "./payload.builder";
3-
import { type RequestHeaderBuilder } from "./request-header.builder";
4-
import { type RequestParamBuilder } from "./request-param.builder";
5-
import { UrlBuilder } from "./url.builder";
1+
import { type PathVariableBuilder } from './path-variable.builder';
2+
import { PayloadBuilder } from './payload.builder';
3+
import { type RequestHeaderBuilder } from './request-header.builder';
4+
import { type RequestParamBuilder } from './request-param.builder';
5+
import { UrlBuilder } from './url.builder';
66
import {
77
PATH_VARIABLE_METADATA,
88
REQUEST_BODY_METADATA,
99
REQUEST_FORM_METADATA,
1010
REQUEST_HEADER_METADATA,
1111
REQUEST_PARAM_METADATA,
12-
} from "../decorators";
13-
import { type HttpMethod } from "../types/http-method";
12+
} from '../decorators';
13+
import { type HttpMethod } from '../types/http-method';
1414

1515
export class HttpRequestBuilder {
16-
private baseUrl = "";
16+
private baseUrl = '';
1717
private readonly pathVariableBuilder?: PathVariableBuilder;
1818
private readonly requestParamBuilder?: RequestParamBuilder;
1919
private readonly requestHeaderBuilder?: RequestHeaderBuilder;
@@ -23,14 +23,14 @@ export class HttpRequestBuilder {
2323
readonly target: object,
2424
readonly propertyKey: string,
2525
readonly method: HttpMethod,
26-
readonly url: string
26+
readonly url: string,
2727
) {
2828
this.pathVariableBuilder = this.getMetadata(PATH_VARIABLE_METADATA);
2929
this.requestParamBuilder = this.getMetadata(REQUEST_PARAM_METADATA);
3030
this.requestHeaderBuilder = this.getMetadata(REQUEST_HEADER_METADATA);
3131
this.payloadBuilder = new PayloadBuilder(
3232
this.getMetadata(REQUEST_BODY_METADATA),
33-
this.getMetadata(REQUEST_FORM_METADATA)
33+
this.getMetadata(REQUEST_FORM_METADATA),
3434
);
3535
}
3636

@@ -44,7 +44,7 @@ export class HttpRequestBuilder {
4444
this.url,
4545
args,
4646
this.pathVariableBuilder,
47-
this.requestParamBuilder
47+
this.requestParamBuilder,
4848
);
4949
const payload = this.payloadBuilder.build(args);
5050
const headers = this.requestHeaderBuilder?.build(args);
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
import { describe, test, expect } from "vitest";
2-
import { PathVariableBuilder } from "./path-variable.builder";
1+
import { describe, test, expect } from 'vitest';
2+
import { PathVariableBuilder } from './path-variable.builder';
33

4-
describe("PathVariableBuilder", () => {
5-
test("should replace url with given variable", () => {
4+
describe('PathVariableBuilder', () => {
5+
test('should replace url with given variable', () => {
66
// given
7-
const builder = new PathVariableBuilder(0, "id");
7+
const builder = new PathVariableBuilder(0, 'id');
88
const args = [123];
99

1010
// when
11-
const actual = builder.build("/user/{id}", args);
11+
const actual = builder.build('/user/{id}', args);
1212

1313
// then
14-
expect(actual).toBe("/user/123");
14+
expect(actual).toBe('/user/123');
1515
});
1616

17-
test("should replace multiple variables in url", () => {
17+
test('should replace multiple variables in url', () => {
1818
// given
19-
const builder = new PathVariableBuilder(0, "id");
20-
builder.add(1, "name");
21-
const url = "/user/{id}/profile/{name}";
22-
const args = [123, "john"];
19+
const builder = new PathVariableBuilder(0, 'id');
20+
builder.add(1, 'name');
21+
const url = '/user/{id}/profile/{name}';
22+
const args = [123, 'john'];
2323

2424
// when
2525
const actual = builder.build(url, args);
2626

2727
// then
28-
expect(actual).toBe("/user/123/profile/john");
28+
expect(actual).toBe('/user/123/profile/john');
2929
});
3030

31-
test("should handle url without variables", () => {
31+
test('should handle url without variables', () => {
3232
// given
33-
const builder = new PathVariableBuilder(0, "id");
33+
const builder = new PathVariableBuilder(0, 'id');
3434
const args = [123];
3535

3636
// when
37-
const actual = builder.build("/user/profile", args);
37+
const actual = builder.build('/user/profile', args);
3838

3939
// then
40-
expect(actual).toBe("/user/profile");
40+
expect(actual).toBe('/user/profile');
4141
});
4242

43-
test("should handle variables not replaced in url", () => {
43+
test('should handle variables not replaced in url', () => {
4444
// given
45-
const builder = new PathVariableBuilder(0, "id");
45+
const builder = new PathVariableBuilder(0, 'id');
4646
const args = [123];
4747

4848
// when
49-
const actual = builder.build("/user/{id}/profile/{name}", args);
49+
const actual = builder.build('/user/{id}/profile/{name}', args);
5050

5151
// then
52-
expect(actual).toBe("/user/123/profile/{name}");
52+
expect(actual).toBe('/user/123/profile/{name}');
5353
});
5454

55-
test("should replace multiple variables with same name", () => {
55+
test('should replace multiple variables with same name', () => {
5656
// given
57-
const builder = new PathVariableBuilder(0, "id");
57+
const builder = new PathVariableBuilder(0, 'id');
5858
const args = [123];
5959

6060
// when
61-
const actual = builder.build("/user/{id}/profile/{id}", args);
61+
const actual = builder.build('/user/{id}/profile/{id}', args);
6262

6363
// then
64-
expect(actual).toBe("/user/123/profile/123");
64+
expect(actual).toBe('/user/123/profile/123');
6565
});
6666
});

lib/builders/path-variable.builder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export class PathVariableBuilder {
1212
build(url: string, args: any[]): string {
1313
return this.metadata.reduce<string>(
1414
(acc, [index, key]) =>
15-
acc.replace(new RegExp(`{${key}}`, "g"), String(args[index])),
16-
url
15+
acc.replace(new RegExp(`{${key}}`, 'g'), String(args[index])),
16+
url,
1717
);
1818
}
1919
}

lib/builders/payload.builder.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { type RequestBodyBuilder } from "./request-body.builder";
2-
import { type RequestFormBuilder } from "./request-form.builder";
1+
import { type RequestBodyBuilder } from './request-body.builder';
2+
import { type RequestFormBuilder } from './request-form.builder';
33

44
export class PayloadBuilder {
55
constructor(
66
private readonly requestBodyBuilder?: RequestBodyBuilder,
7-
private readonly requestFormBuilder?: RequestFormBuilder
7+
private readonly requestFormBuilder?: RequestFormBuilder,
88
) {}
99

10-
get contentType(): { "Content-Type": string } | undefined {
10+
get contentType(): { 'Content-Type': string } | undefined {
1111
if (this.requestBodyBuilder != null) {
12-
return { "Content-Type": "application/json" };
12+
return { 'Content-Type': 'application/json' };
1313
}
1414

1515
if (this.requestFormBuilder != null) {
16-
return { "Content-Type": "application/x-www-form-urlencoded" };
16+
return { 'Content-Type': 'application/x-www-form-urlencoded' };
1717
}
1818

1919
return undefined;

lib/builders/request-body.builder.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { describe, test, expect } from "vitest";
2-
import { RequestBodyBuilder } from "./request-body.builder";
1+
import { describe, test, expect } from 'vitest';
2+
import { RequestBodyBuilder } from './request-body.builder';
33

4-
describe("RequestBodyBuilder", () => {
5-
test("should build json string with explicit key", () => {
4+
describe('RequestBodyBuilder', () => {
5+
test('should build json string with explicit key', () => {
66
// given
7-
const builder = new RequestBodyBuilder(0, "keyword");
8-
const args = ["search"];
7+
const builder = new RequestBodyBuilder(0, 'keyword');
8+
const args = ['search'];
99

1010
// when
1111
const actual = builder.build(args);
@@ -14,10 +14,10 @@ describe("RequestBodyBuilder", () => {
1414
expect(actual).toBe('{"keyword":"search"}');
1515
});
1616

17-
test("should build json string without key", () => {
17+
test('should build json string without key', () => {
1818
// given
1919
const builder = new RequestBodyBuilder(1);
20-
const args = ["invalid", { foo: "bar" }];
20+
const args = ['invalid', { foo: 'bar' }];
2121

2222
// when
2323
const actual = builder.build(args);

lib/builders/request-body.builder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TupleArrayBuilder } from "./tuple-array.builder";
1+
import { TupleArrayBuilder } from './tuple-array.builder';
22

33
export class RequestBodyBuilder {
44
metadata: Array<[index: number, key: string | undefined]> = [];
@@ -22,12 +22,12 @@ export class RequestBodyBuilder {
2222
TupleArrayBuilder.of<string, unknown>(args[index]).forEach(
2323
([key, value]) => {
2424
acc[key] = value;
25-
}
25+
},
2626
);
2727

2828
return acc;
2929
},
30-
{}
30+
{},
3131
);
3232

3333
return JSON.stringify(result);
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import { describe, test, expect } from "vitest";
2-
import { RequestFormBuilder } from "./request-form.builder";
1+
import { describe, test, expect } from 'vitest';
2+
import { RequestFormBuilder } from './request-form.builder';
33

4-
describe("RequestFormBuilder", () => {
5-
test("should build form data with explicit key", () => {
4+
describe('RequestFormBuilder', () => {
5+
test('should build form data with explicit key', () => {
66
// given
7-
const builder = new RequestFormBuilder(0, "keyword");
8-
const args = ["search"];
7+
const builder = new RequestFormBuilder(0, 'keyword');
8+
const args = ['search'];
99

1010
// when
1111
const actual = builder.build(args);
1212

1313
// then
14-
expect([...actual.entries()]).toEqual([["keyword", "search"]]);
14+
expect([...actual.entries()]).toEqual([['keyword', 'search']]);
1515
});
1616

17-
test("should build form data without key", () => {
17+
test('should build form data without key', () => {
1818
// given
1919
const builder = new RequestFormBuilder(1);
20-
const args = ["invalid", { foo: "bar" }];
20+
const args = ['invalid', { foo: 'bar' }];
2121

2222
// when
2323
const actual = builder.build(args);
2424

2525
// then
26-
expect([...actual.entries()]).toEqual([["foo", "bar"]]);
26+
expect([...actual.entries()]).toEqual([['foo', 'bar']]);
2727
});
2828
});

lib/builders/request-form.builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TupleArrayBuilder } from "./tuple-array.builder";
1+
import { TupleArrayBuilder } from './tuple-array.builder';
22

33
export class RequestFormBuilder {
44
metadata: Array<[index: number, key: string | undefined]> = [];
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import { describe, test, expect } from "vitest";
2-
import { RequestHeaderBuilder } from "./request-header.builder";
1+
import { describe, test, expect } from 'vitest';
2+
import { RequestHeaderBuilder } from './request-header.builder';
33

4-
describe("RequestHeaderBuilder", () => {
5-
test("should build header with explicit key", () => {
4+
describe('RequestHeaderBuilder', () => {
5+
test('should build header with explicit key', () => {
66
// given
7-
const builder = new RequestHeaderBuilder(0, "keyword");
8-
const args = ["search"];
7+
const builder = new RequestHeaderBuilder(0, 'keyword');
8+
const args = ['search'];
99

1010
// when
1111
const actual = builder.build(args);
1212

1313
// then
14-
expect(actual).toEqual({ keyword: "search" });
14+
expect(actual).toEqual({ keyword: 'search' });
1515
});
1616

17-
test("should build header without key", () => {
17+
test('should build header without key', () => {
1818
// given
1919
const builder = new RequestHeaderBuilder(1);
20-
const args = ["invalid", { foo: "bar" }];
20+
const args = ['invalid', { foo: 'bar' }];
2121

2222
// when
2323
const actual = builder.build(args);
2424

2525
// then
26-
expect(actual).toEqual({ foo: "bar" });
26+
expect(actual).toEqual({ foo: 'bar' });
2727
});
2828
});

0 commit comments

Comments
 (0)