Skip to content

Commit

Permalink
feat: ✨ improve message creation
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmannZ committed Apr 20, 2024
1 parent eddfa94 commit b7dc0e0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions protobuf-ts/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import {
} from "./proto/test";

export const readInputsCall = (client: TestServiceClient) => {
const request = TestServiceReadInputsRequest.create({
const request: TestServiceReadInputsRequest = {
userId: faker.string.uuid(),
taxYear: faker.number.int({ min: 2018, max: 2023 }).toString(),
formName: faker.helpers.arrayElement(MOCK_FORM_NAMES),
inputNames: MOCK_INPUT_NAMES,
});
};

const metadata = new Metadata();

Expand All @@ -37,7 +37,7 @@ export const readInputsCall = (client: TestServiceClient) => {
};

export const updateInputsCall = (client: TestServiceClient) => {
const request = TestServiceUpdateInputsRequest.create({
const request: TestServiceUpdateInputsRequest = {
userId: faker.string.uuid(),
taxYear: faker.number.int({ min: 2018, max: 2023 }).toString(),
formName: faker.helpers.arrayElement(MOCK_FORM_NAMES),
Expand All @@ -47,7 +47,7 @@ export const updateInputsCall = (client: TestServiceClient) => {
type: faker.helpers.arrayElement(MOCK_INPUT_TYPES),
source: faker.helpers.arrayElement(MOCK_INPUT_SOURCES),
})),
});
};

const metadata = new Metadata();

Expand Down
6 changes: 3 additions & 3 deletions protobuf-ts/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const readInputs: handleUnaryCall<
});
});

const response = TestServiceReadInputsResponse.create({
const response: TestServiceReadInputsResponse = {
inputs,
});
};

callback(null, response);
};
Expand All @@ -53,7 +53,7 @@ const updateInputs: handleUnaryCall<

inputs.forEach(() => {});

const response = TestServiceUpdateInputsResponse.create();
const response: TestServiceUpdateInputsResponse = {};

callback(null, response);
};
Expand Down
2 changes: 1 addition & 1 deletion ts-proto/gen_grpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ echo "\t└> $SRC_DEST_DIR"
$GRPC_TOOLS_NODE_PROTOC_PATH \
--plugin=$PROTOC_GEN_TS_PROTO_PATH \
--ts_proto_out=$SRC_DEST_DIR \
--ts_proto_opt=outputServices=grpc-js \
--ts_proto_opt=removeEnumPrefix=true,outputServices=grpc-js \
-I $PROTO_DIR $PROTO_FILES
8 changes: 4 additions & 4 deletions ts-proto/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
} from "./proto/test";

export const readInputsCall = (client: TestServiceClient) => {
const request = TestServiceReadInputsRequest.fromPartial({
const request: TestServiceReadInputsRequest = {
userId: faker.string.uuid(),
taxYear: faker.number.int({ min: 2018, max: 2023 }).toString(),
formName: faker.helpers.arrayElement(MOCK_FORM_NAMES),
inputNames: MOCK_INPUT_NAMES,
});
};

const metadata = new Metadata();

Expand All @@ -36,7 +36,7 @@ export const readInputsCall = (client: TestServiceClient) => {
};

export const updateInputsCall = (client: TestServiceClient) => {
const request = TestServiceUpdateInputsRequest.fromPartial({
const request: TestServiceUpdateInputsRequest = {
userId: faker.string.uuid(),
taxYear: faker.number.int({ min: 2018, max: 2023 }).toString(),
formName: faker.helpers.arrayElement(MOCK_FORM_NAMES),
Expand All @@ -46,7 +46,7 @@ export const updateInputsCall = (client: TestServiceClient) => {
type: faker.helpers.arrayElement(MOCK_INPUT_TYPES),
source: faker.helpers.arrayElement(MOCK_INPUT_SOURCES),
})),
});
};

const metadata = new Metadata();

Expand Down
6 changes: 3 additions & 3 deletions ts-proto/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const readInputs: handleUnaryCall<
});
});

const response = TestServiceReadInputsResponse.fromPartial({
const response: TestServiceReadInputsResponse = {
inputs,
});
};

callback(null, response);
};
Expand All @@ -52,7 +52,7 @@ const updateInputs: handleUnaryCall<

inputs.forEach(() => {});

const response = TestServiceUpdateInputsResponse.fromPartial({});
const response: TestServiceUpdateInputsResponse = {};

callback(null, response);
};
Expand Down

0 comments on commit b7dc0e0

Please sign in to comment.