-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: public user profiles, caching, discover doctors, organizations
- Loading branch information
Ruslan Garifullin
committed
Apr 22, 2023
1 parent
0c32983
commit 8e385cd
Showing
37 changed files
with
2,124 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./organization-details.dto"; | ||
export * from "./public-profile.dto"; | ||
export * from "./update-public-profile.dto"; |
8 changes: 8 additions & 0 deletions
8
packages/js/shared/web2-common/src/dto/user/organization-details.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { array, partial, string, TypeOf } from "io-ts"; | ||
|
||
export const UserOrganizationDetailsDto = partial({ | ||
email_domains: array(string), | ||
website: string, | ||
}); | ||
|
||
export type UserOrganizationDetailsDto = TypeOf<typeof UserOrganizationDetailsDto>; |
15 changes: 15 additions & 0 deletions
15
packages/js/shared/web2-common/src/dto/user/public-profile.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { array, partial, record, string, type, TypeOf } from "io-ts"; | ||
|
||
export const UserPublicProfileDto = partial({ | ||
full_name: string, | ||
avatar: string, | ||
organization_id: string, | ||
location: string, | ||
languages: array(string), | ||
areasOfFocus: string, | ||
specialty: string, | ||
timetable: array(array(string)), | ||
socials: array(type({ name: string, value: string })) | ||
}); | ||
|
||
export type UserPublicProfileDto = TypeOf<typeof UserPublicProfileDto>; |
12 changes: 12 additions & 0 deletions
12
packages/js/shared/web2-common/src/dto/user/update-public-profile.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { type, string, TypeOf, any } from "io-ts"; | ||
import { web3AddressType } from "../../types/web3-address.type"; | ||
import { UserPublicProfileDto } from "./public-profile.dto"; | ||
|
||
export const UpdatePublicProfileDto = type({ | ||
address: web3AddressType, | ||
message: any, | ||
signed: string, | ||
public_profile: UserPublicProfileDto | ||
}); | ||
|
||
export type UpdatePublicProfileDto = TypeOf<typeof UpdatePublicProfileDto>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { UserEntity } from "@hdapp/shared/db-common/entities"; | ||
import { getRightOrFail } from "@hdapp/shared/web2-common/io-ts-utils/get-right"; | ||
import { web3AddressType } from "@hdapp/shared/web2-common/types"; | ||
import { FriendlyError } from "@hdapp/shared/web2-common/utils"; | ||
import { Injectable, UnauthorizedException } from "@nestjs/common"; | ||
import { PassportStrategy } from "@nestjs/passport"; | ||
import Strategy from "passport-dapp-web3"; | ||
import { UsersService } from "../users/users.service"; | ||
|
||
@Injectable() | ||
export class Web3Strategy extends PassportStrategy(Strategy) { | ||
constructor(private users: UsersService) { | ||
super({ session: false }); | ||
} | ||
|
||
async validate(address: string): Promise<UserEntity> { | ||
try { | ||
const web3Address = getRightOrFail(web3AddressType.decode(address)); | ||
return await this.users.findOneByWeb3Address(web3Address); | ||
} catch (e) { | ||
if (e instanceof FriendlyError) | ||
throw new UnauthorizedException({ message: e.message }); | ||
|
||
throw e; | ||
} | ||
} | ||
} |
Oops, something went wrong.