|
| 1 | +import { ApiProperty } from '@nestjs/swagger'; |
| 2 | +import { Type } from 'class-transformer'; |
| 3 | +import { |
| 4 | + IsOptional, |
| 5 | + IsString, |
| 6 | + IsUrl, |
| 7 | + Matches, |
| 8 | + MaxLength, |
| 9 | + MinLength, |
| 10 | +} from 'class-validator'; |
| 11 | + |
| 12 | +export const LinkRegexes = { |
| 13 | + bandcamp: /https?:\/\/[a-zA-Z0-9_-]+\.bandcamp\.com\/?/, |
| 14 | + discord: /https?:\/\/(www\.)?discord\.com\/[a-zA-Z0-9_]+/, |
| 15 | + facebook: /https?:\/\/(www\.)?facebook\.com\/[a-zA-Z0-9_]+/, |
| 16 | + github: /https?:\/\/(www\.)?github\.com\/[a-zA-Z0-9_-]+/, |
| 17 | + instagram: /https?:\/\/(www\.)?instagram\.com\/[a-zA-Z0-9_]+/, |
| 18 | + reddit: /https?:\/\/(www\.)?reddit\.com\/user\/[a-zA-Z0-9_-]+/, |
| 19 | + snapchat: /https?:\/\/(www\.)?snapchat\.com\/add\/[a-zA-Z0-9_-]+/, |
| 20 | + soundcloud: /https?:\/\/(www\.)?soundcloud\.com\/[a-zA-Z0-9_-]+/, |
| 21 | + spotify: /https?:\/\/open\.spotify\.com\/artist\/[a-zA-Z0-9?&=]+/, |
| 22 | + steam: /https?:\/\/steamcommunity\.com\/id\/[a-zA-Z0-9_-]+/, |
| 23 | + telegram: /https?:\/\/(www\.)?t\.me\/[a-zA-Z0-9_]+/, |
| 24 | + tiktok: /https?:\/\/(www\.)?tiktok\.com\/@?[a-zA-Z0-9_]+/, |
| 25 | + threads: /https?:\/\/(www\.)?threads\.net\/@?[a-zA-Z0-9_]+/, |
| 26 | + twitch: /https?:\/\/(www\.)?twitch\.tv\/[a-zA-Z0-9_]+/, |
| 27 | + x: /https?:\/\/(www\.)?x\.com\/[a-zA-Z0-9_]+/, |
| 28 | + youtube: /https?:\/\/(www\.)?youtube\.com\/@?[a-zA-Z0-9_-]+/, |
| 29 | +}; |
| 30 | + |
| 31 | +export class UserLinks { |
| 32 | + @IsOptional() |
| 33 | + @IsUrl() |
| 34 | + @Matches(LinkRegexes.bandcamp) |
| 35 | + bandcamp?: string; |
| 36 | + |
| 37 | + @IsOptional() |
| 38 | + @IsUrl() |
| 39 | + @Matches(LinkRegexes.discord) |
| 40 | + discord?: string; |
| 41 | + |
| 42 | + @IsOptional() |
| 43 | + @IsUrl() |
| 44 | + @Matches(LinkRegexes.facebook) |
| 45 | + facebook?: string; |
| 46 | + |
| 47 | + @IsOptional() |
| 48 | + @IsUrl() |
| 49 | + @Matches(LinkRegexes.github) |
| 50 | + github?: string; |
| 51 | + |
| 52 | + @IsOptional() |
| 53 | + @IsUrl() |
| 54 | + @Matches(LinkRegexes.instagram) |
| 55 | + instagram?: string; |
| 56 | + |
| 57 | + @IsOptional() |
| 58 | + @IsUrl() |
| 59 | + @Matches(LinkRegexes.reddit) |
| 60 | + reddit?: string; |
| 61 | + |
| 62 | + @IsOptional() |
| 63 | + @IsUrl() |
| 64 | + @Matches(LinkRegexes.snapchat) |
| 65 | + snapchat?: string; |
| 66 | + |
| 67 | + @IsOptional() |
| 68 | + @IsUrl() |
| 69 | + @Matches(LinkRegexes.soundcloud) |
| 70 | + soundcloud?: string; |
| 71 | + |
| 72 | + @IsOptional() |
| 73 | + @IsUrl() |
| 74 | + @Matches(LinkRegexes.spotify) |
| 75 | + spotify?: string; |
| 76 | + |
| 77 | + @IsOptional() |
| 78 | + @IsUrl() |
| 79 | + @Matches(LinkRegexes.steam) |
| 80 | + steam?: string; |
| 81 | + |
| 82 | + @IsOptional() |
| 83 | + @IsUrl() |
| 84 | + @Matches(LinkRegexes.telegram) |
| 85 | + telegram?: string; |
| 86 | + |
| 87 | + @IsOptional() |
| 88 | + @IsUrl() |
| 89 | + @Matches(LinkRegexes.tiktok) |
| 90 | + tiktok?: string; |
| 91 | + |
| 92 | + @IsOptional() |
| 93 | + @IsUrl() |
| 94 | + @Matches(LinkRegexes.threads) |
| 95 | + threads?: string; |
| 96 | + |
| 97 | + @IsOptional() |
| 98 | + @IsUrl() |
| 99 | + @Matches(LinkRegexes.twitch) |
| 100 | + twitch?: string; |
| 101 | + |
| 102 | + @IsOptional() |
| 103 | + @IsUrl() |
| 104 | + @Matches(LinkRegexes.x) |
| 105 | + x?: string; |
| 106 | + |
| 107 | + @IsOptional() |
| 108 | + @IsUrl() |
| 109 | + @Matches(LinkRegexes.youtube) |
| 110 | + youtube?: string; |
| 111 | +} |
| 112 | + |
| 113 | +export class UpdateUserProfileDto { |
| 114 | + @IsString() |
| 115 | + @MaxLength(64) |
| 116 | + @MinLength(3) |
| 117 | + @IsOptional() |
| 118 | + @ApiProperty({ |
| 119 | + description: 'Username of the user', |
| 120 | + example: 'tomast1137', |
| 121 | + }) |
| 122 | + username?: string; |
| 123 | + |
| 124 | + @IsOptional() |
| 125 | + @IsString() |
| 126 | + @MaxLength(1024) |
| 127 | + @ApiProperty({ |
| 128 | + description: 'Description of the user', |
| 129 | + example: 'I using noteblock.world', |
| 130 | + }) |
| 131 | + description?: string; |
| 132 | + |
| 133 | + @IsOptional() |
| 134 | + @Type(() => UserLinks) |
| 135 | + @ApiProperty({ |
| 136 | + description: 'Social media links of the user', |
| 137 | + example: { |
| 138 | + github: 'https://github.com/tomast1337', |
| 139 | + youtube: 'https://www.youtube.com/@Bentroen_', |
| 140 | + spotify: |
| 141 | + 'https://open.spotify.com/artist/1McMsnEElThX1knmY4oliG?si=v95i3XbRRgKT9JwyiFiFEg', |
| 142 | + bandcamp: 'https://igorrr.bandcamp.com/', |
| 143 | + facebook: 'https://www.facebook.com/MrBean', |
| 144 | + reddit: 'https://www.reddit.com/user/Unidan/', |
| 145 | + soundcloud: 'https://soundcloud.com/futureisnow', |
| 146 | + steam: 'https://steamcommunity.com/id/CattleDecapitation/', |
| 147 | + x: 'https://x.com/Trail_Cams', |
| 148 | + twitch: 'https://www.twitch.tv/vinesauce', |
| 149 | + threads: 'https://www.threads.net/@kimkardashian', |
| 150 | + tiktok: 'https://www.tiktok.com/@karolg', |
| 151 | + snapchat: 'https://www.snapchat.com/add/username', |
| 152 | + instagram: 'https://instagram.com/validuser', |
| 153 | + discord: 'https://discord.com/validuser', |
| 154 | + telegram: 'https://t.me/validuser', |
| 155 | + }, |
| 156 | + }) |
| 157 | + socialLinks?: UserLinks; |
| 158 | +} |
0 commit comments