Skip to content

Commit

Permalink
chore: remove rest of "grpc." prefixs from utils.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
CaramelKat authored Jul 24, 2024
1 parent c54e44f commit 52b47f7
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const communityMap = new HashMap<string, string>();
const userMap = new HashMap<number, string>();

const { ip: friendsIP, port: friendsPort, api_key: friendsKey } = config.grpc.friends;
const friendsChannel = grpc.createChannel(`${friendsIP}:${friendsPort}`);
const friendsClient = grpc.createClient(FriendsDefinition, friendsChannel);
const friendsChannel = createChannel(`${friendsIP}:${friendsPort}`);
const friendsClient = createClient(FriendsDefinition, friendsChannel);

const { ip: apiIP, port: apiPort, api_key: apiKey } = config.grpc.account;
const apiChannel = grpc.createChannel(`${apiIP}:${apiPort}`);
const apiClient = grpc.createClient(APIDefinition, apiChannel);
const apiChannel = createChannel(`${apiIP}:${apiPort}`);
const apiClient = createClient(APIDefinition, apiChannel);

const accountChannel = grpc.createChannel(`${apiIP}:${apiPort}`);
const accountClient = grpc.createClient(AccountDefinition, accountChannel);
const accountChannel = createChannel(`${apiIP}:${apiPort}`);
const accountClient = createClient(AccountDefinition, accountChannel);

const spacesEndpoint = new aws.Endpoint('nyc3.digitaloceanspaces.com');
const s3 = new aws.S3({
Expand Down Expand Up @@ -382,7 +382,7 @@ export async function getFriends(pid: number): Promise<number[]> {
const pids = await friendsClient.getUserFriendPIDs({
pid: pid
}, {
metadata: grpc.Metadata({
metadata: Metadata({
'X-API-Key': friendsKey
})
});
Expand All @@ -397,7 +397,7 @@ export async function getFriendRequests(pid: number): Promise<FriendRequest[]> {
const requests = await friendsClient.getUserFriendRequestsIncoming({
pid: pid
}, {
metadata: grpc.Metadata({
metadata: Metadata({
'X-API-Key': friendsKey
})
});
Expand All @@ -413,7 +413,7 @@ export async function login(username: string, password: string): Promise<ApiLogi
password: password,
grantType: 'password'
}, {
metadata: grpc.Metadata({
metadata: Metadata({
'X-API-Key': apiKey
})
});
Expand All @@ -423,15 +423,15 @@ export async function refreshLogin(refreshToken: string): Promise<ApiLoginRespon
return await apiClient.login({
refreshToken: refreshToken
}, {
metadata: grpc.Metadata({
metadata: Metadata({
'X-API-Key': apiKey
})
});
}

export async function getUserDataFromToken(token: string): Promise<User> {
return apiClient.getUserData({}, {
metadata: grpc.Metadata({
metadata: Metadata({
'X-API-Key': apiKey,
'X-Token': token
})
Expand All @@ -442,7 +442,7 @@ export async function getUserDataFromPid(pid: number): Promise<User> {
return accountClient.getUserData({
pid: pid
}, {
metadata: grpc.Metadata({
metadata: Metadata({
'X-API-Key': apiKey
})
});
Expand All @@ -451,4 +451,4 @@ export async function getUserDataFromPid(pid: number): Promise<User> {
export async function getPid(token: string): Promise<number> {
const user = await getUserDataFromToken(token);
return user.pid;
}
}

0 comments on commit 52b47f7

Please sign in to comment.