|
| 1 | +/** |
| 2 | + * *-manual.ts is where end user specifiy which fields should be sanitized manually |
| 3 | + **/ |
| 4 | + |
| 5 | +import { t } from 'elysia' |
| 6 | +import { benchmark } from './utils' |
| 7 | + |
| 8 | +benchmark( |
| 9 | + t.Array( |
| 10 | + t.Object({ |
| 11 | + id: t.Number(), |
| 12 | + name: t.String(), |
| 13 | + bio: t.String({ |
| 14 | + sanitize: true |
| 15 | + }), |
| 16 | + user: t.Object({ |
| 17 | + name: t.String(), |
| 18 | + password: t.String(), |
| 19 | + email: t.Optional(t.String({ format: 'email' })), |
| 20 | + age: t.Optional(t.Number()), |
| 21 | + avatar: t.Optional(t.String({ format: 'uri' })), |
| 22 | + cover: t.Optional(t.String({ format: 'uri' })) |
| 23 | + }), |
| 24 | + playing: t.Optional(t.String()), |
| 25 | + wishlist: t.Optional(t.Array(t.Number())), |
| 26 | + games: t.Array( |
| 27 | + t.Object({ |
| 28 | + id: t.Number(), |
| 29 | + name: t.String(), |
| 30 | + hoursPlay: t.Optional(t.Number({ default: 0 })), |
| 31 | + tags: t.Array( |
| 32 | + t.Object({ |
| 33 | + name: t.String(), |
| 34 | + count: t.Number() |
| 35 | + }) |
| 36 | + ) |
| 37 | + }) |
| 38 | + ), |
| 39 | + metadata: t.Intersect([ |
| 40 | + t.Object({ |
| 41 | + alias: t.String() |
| 42 | + }), |
| 43 | + t.Object({ |
| 44 | + country: t.Nullable(t.String()), |
| 45 | + region: t.Optional(t.String()) |
| 46 | + }) |
| 47 | + ]), |
| 48 | + social: t.Optional( |
| 49 | + t.Object({ |
| 50 | + facebook: t.Optional(t.String()), |
| 51 | + twitter: t.Optional(t.String()), |
| 52 | + youtube: t.Optional(t.String()) |
| 53 | + }) |
| 54 | + ) |
| 55 | + }) |
| 56 | + ), |
| 57 | + [ |
| 58 | + { |
| 59 | + id: 1, |
| 60 | + name: 'SaltyAom', |
| 61 | + bio: 'I like train\n', |
| 62 | + user: { |
| 63 | + name: 'SaltyAom', |
| 64 | + password: '123456', |
| 65 | + avatar: 'https://avatars.githubusercontent.com/u/35027979?v=4', |
| 66 | + cover: 'https://saltyaom.com/cosplay/pekomama.webp' |
| 67 | + }, |
| 68 | + playing: 'Strinova', |
| 69 | + wishlist: [4_154_456, 2_345_345], |
| 70 | + games: [ |
| 71 | + { |
| 72 | + id: 4_154_456, |
| 73 | + name: 'MiSide', |
| 74 | + hoursPlay: 17, |
| 75 | + tags: [ |
| 76 | + { name: 'Psychological Horror', count: 236_432 }, |
| 77 | + { name: 'Cute', count: 495_439 }, |
| 78 | + { name: 'Dating Sim', count: 395_532 } |
| 79 | + ] |
| 80 | + }, |
| 81 | + { |
| 82 | + id: 4_356_345, |
| 83 | + name: 'Strinova', |
| 84 | + hoursPlay: 365, |
| 85 | + tags: [ |
| 86 | + { name: 'Free to Play', count: 205_593 }, |
| 87 | + { name: 'Anime', count: 504_304 }, |
| 88 | + { name: 'Third-Person Shooter', count: 395_532 } |
| 89 | + ] |
| 90 | + }, |
| 91 | + { |
| 92 | + id: 2_345_345, |
| 93 | + name: "Tom Clancy's Rainbow Six Siege", |
| 94 | + hoursPlay: 287, |
| 95 | + tags: [ |
| 96 | + { name: 'FPS', count: 855_324 }, |
| 97 | + { name: 'Multiplayer', count: 456_567 }, |
| 98 | + { name: 'Tactical', count: 544_467 } |
| 99 | + ] |
| 100 | + } |
| 101 | + ], |
| 102 | + metadata: { |
| 103 | + alias: 'SaltyAom', |
| 104 | + country: 'Thailand', |
| 105 | + region: 'Asia' |
| 106 | + }, |
| 107 | + social: { |
| 108 | + twitter: 'SaltyAom' |
| 109 | + } |
| 110 | + }, |
| 111 | + { |
| 112 | + id: 2, |
| 113 | + name: 'VLost', |
| 114 | + bio: 'ไม่พี่คืองี้\n', |
| 115 | + user: { |
| 116 | + name: 'nattapon_kub', |
| 117 | + password: '123456' |
| 118 | + }, |
| 119 | + games: [ |
| 120 | + { |
| 121 | + id: 4_154_456, |
| 122 | + name: 'MiSide', |
| 123 | + hoursPlay: 17, |
| 124 | + tags: [ |
| 125 | + { name: 'Psychological Horror', count: 236_432 }, |
| 126 | + { name: 'Cute', count: 495_439 }, |
| 127 | + { name: 'Dating Sim', count: 395_532 } |
| 128 | + ] |
| 129 | + }, |
| 130 | + { |
| 131 | + id: 4_356_345, |
| 132 | + name: 'Strinova', |
| 133 | + hoursPlay: 365, |
| 134 | + tags: [ |
| 135 | + { name: 'Free to Play', count: 205_593 }, |
| 136 | + { name: 'Anime', count: 504_304 }, |
| 137 | + { name: 'Third-Person Shooter', count: 395_532 } |
| 138 | + ] |
| 139 | + } |
| 140 | + ], |
| 141 | + metadata: { |
| 142 | + alias: 'vlost', |
| 143 | + country: 'Thailand' |
| 144 | + } |
| 145 | + }, |
| 146 | + { |
| 147 | + id: 2, |
| 148 | + name: 'eika', |
| 149 | + bio: 'こんにちわ!', |
| 150 | + user: { |
| 151 | + name: 'ei_ka', |
| 152 | + password: '123456' |
| 153 | + }, |
| 154 | + games: [ |
| 155 | + { |
| 156 | + id: 4_356_345, |
| 157 | + name: 'Strinova', |
| 158 | + hoursPlay: 365, |
| 159 | + tags: [ |
| 160 | + { name: 'Free to Play', count: 205_593 }, |
| 161 | + { name: 'Anime', count: 504_304 }, |
| 162 | + { name: 'Third-Person Shooter', count: 395_532 } |
| 163 | + ] |
| 164 | + } |
| 165 | + ], |
| 166 | + metadata: { |
| 167 | + alias: 'eika', |
| 168 | + country: 'Japan' |
| 169 | + } |
| 170 | + } |
| 171 | + ], |
| 172 | + { |
| 173 | + sanitize: 'manual' |
| 174 | + } |
| 175 | +) |
0 commit comments