Skip to content

Commit c4f2f53

Browse files
committed
fix: provider transform
1 parent 96983f8 commit c4f2f53

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
"passport-apple": "^1.1.1",
3939
"passport-google-oauth": "^2.0.0",
4040
"passport-twitter": "^1.0.4",
41-
"protobufjs": "^6.10.2"
41+
"protobufjs": "github:iFwu/protobuf.js"
4242
}
4343
}

src/services/userService.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UserService } from '../../generated/services/user';
1+
import { UserService, Provider as GProvider } from '../../generated/services/user';
22
import { Provider } from '../models/provider';
33
import { createClient, wrapGrpcRequestMethodFactory } from './grpc';
44

@@ -11,7 +11,21 @@ const userServiceClient = createClient(
1111
const methodWrapper = wrapGrpcRequestMethodFactory(userServiceClient);
1212

1313
export const userService = {
14-
getOrCreateUser: methodWrapper<typeof userServiceClient.getOrCreateUser, { provider: Provider; socialId: string }>(
15-
userServiceClient.getOrCreateUser,
16-
),
14+
getOrCreateUser: methodWrapper(userServiceClient.getOrCreateUser, {
15+
to: (req: { provider: Provider; socialId: string }) => ({
16+
provider: toGrpcProvider(req.provider),
17+
socialId: req.socialId,
18+
}),
19+
}),
1720
};
21+
22+
function toGrpcProvider(p: Provider): GProvider {
23+
switch (p) {
24+
case 'google':
25+
return GProvider.Google;
26+
case 'twitter':
27+
return GProvider.Twitter;
28+
case 'apple':
29+
return GProvider.Apple;
30+
}
31+
}

yarn.lock

+25-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
183183
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==
184184

185-
"@types/long@^4.0.1":
185+
"@types/long@^4.0.0", "@types/long@^4.0.1":
186186
version "4.0.1"
187187
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9"
188188
integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==
@@ -202,6 +202,11 @@
202202
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.37.tgz#a3dd8da4eb84a996c36e331df98d82abd76b516e"
203203
integrity sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw==
204204

205+
"@types/node@^10.1.0":
206+
version "10.17.56"
207+
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.56.tgz#010c9e047c3ff09ddcd11cbb6cf5912725cdc2b3"
208+
integrity sha512-LuAa6t1t0Bfw4CuSR0UITsm1hP17YL+u82kfHGrHUWdhlBtH7sa7jGY5z7glGaIj/WDYDkRtgGd+KCjCzxBW1w==
209+
205210
"@types/node@^13.7.0":
206211
version "13.13.48"
207212
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.48.tgz#46a3df718aed5217277f2395a682e055a487e341"
@@ -1637,7 +1642,7 @@ progress@^2.0.0:
16371642
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
16381643
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
16391644

1640-
protobufjs@^6.10.2, protobufjs@^6.8.6:
1645+
protobufjs@^6.8.6:
16411646
version "6.10.2"
16421647
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.10.2.tgz#b9cb6bd8ec8f87514592ba3fdfd28e93f33a469b"
16431648
integrity sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==
@@ -1656,6 +1661,24 @@ protobufjs@^6.10.2, protobufjs@^6.8.6:
16561661
"@types/node" "^13.7.0"
16571662
long "^4.0.0"
16581663

1664+
"protobufjs@github:iFwu/protobuf.js":
1665+
version "6.8.8"
1666+
resolved "https://codeload.github.com/iFwu/protobuf.js/tar.gz/bec020a0071f60a9425efb0d237b84be7ef9e054"
1667+
dependencies:
1668+
"@protobufjs/aspromise" "^1.1.2"
1669+
"@protobufjs/base64" "^1.1.2"
1670+
"@protobufjs/codegen" "^2.0.4"
1671+
"@protobufjs/eventemitter" "^1.1.0"
1672+
"@protobufjs/fetch" "^1.1.0"
1673+
"@protobufjs/float" "^1.0.2"
1674+
"@protobufjs/inquire" "^1.1.0"
1675+
"@protobufjs/path" "^1.1.2"
1676+
"@protobufjs/pool" "^1.1.0"
1677+
"@protobufjs/utf8" "^1.1.0"
1678+
"@types/long" "^4.0.0"
1679+
"@types/node" "^10.1.0"
1680+
long "^4.0.0"
1681+
16591682
proxy-addr@~2.0.5:
16601683
version "2.0.6"
16611684
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf"

0 commit comments

Comments
 (0)