Skip to content

Commit ef24f0c

Browse files
authored
Merge pull request #35 from Selecro/id-to-uudi
Id to uudi
2 parents 8b4a138 + e7b332f commit ef24f0c

14 files changed

+216
-154
lines changed

src/controllers/instruction-step.controller.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class InstructionStepController {
4949
},
5050
})
5151
async createStep(
52-
@param.path.number('instructionId') instructionId: number,
52+
@param.path.string('instructionId') instructionId: string,
5353
@requestBody({
5454
content: {
5555
'application/json': {
@@ -111,8 +111,8 @@ export class InstructionStepController {
111111
},
112112
})
113113
async patchStep(
114-
@param.path.number('instructionId') instructionId: number,
115-
@param.path.number('stepId') stepId: number,
114+
@param.path.string('instructionId') instructionId: string,
115+
@param.path.string('stepId') stepId: string,
116116
@requestBody({
117117
content: {
118118
'application/json': {
@@ -175,8 +175,8 @@ export class InstructionStepController {
175175
},
176176
})
177177
async deleteStep(
178-
@param.path.number('instructionId') instructionId: number,
179-
@param.path.number('stepId') stepId: number,
178+
@param.path.string('instructionId') instructionId: string,
179+
@param.path.string('stepId') stepId: string,
180180
): Promise<boolean> {
181181
const user = await this.userRepository.findById(this.user.id);
182182
if (!user) {
@@ -213,7 +213,7 @@ export class InstructionStepController {
213213
steps: {
214214
type: 'object',
215215
items: {
216-
id: {type: 'number'},
216+
id: {type: 'string'},
217217
titleCz: {type: 'string'},
218218
titleEn: {type: 'string'},
219219
descriptionCz: {
@@ -240,7 +240,7 @@ export class InstructionStepController {
240240
},
241241
})
242242
async getSteps(
243-
@param.path.number('instructionId') instructionId: number,
243+
@param.path.string('instructionId') instructionId: string,
244244
): Promise<Omit<Step, 'deleteHash'>[]> {
245245
const user = await this.userRepository.findById(this.user.id);
246246
if (!user) {
@@ -275,8 +275,8 @@ export class InstructionStepController {
275275
},
276276
})
277277
async uploadStepsPicture(
278-
@param.path.number('instructionId') instructionId: number,
279-
@param.path.number('stepId') stepId: number,
278+
@param.path.string('instructionId') instructionId: string,
279+
@param.path.string('stepId') stepId: string,
280280
@requestBody({
281281
content: {
282282
'multipart/form-data': {
@@ -336,8 +336,8 @@ export class InstructionStepController {
336336
},
337337
})
338338
async deleteStepPicture(
339-
@param.path.number('instructionId') instructionId: number,
340-
@param.path.number('stepId') stepId: number,
339+
@param.path.string('instructionId') instructionId: string,
340+
@param.path.string('stepId') stepId: string,
341341
): Promise<boolean> {
342342
const user = await this.userRepository.findById(this.user.id);
343343
if (!user) {
@@ -378,7 +378,7 @@ export class InstructionStepController {
378378
steps: {
379379
type: 'object',
380380
items: {
381-
id: {type: 'number'},
381+
id: {type: 'string'},
382382
titleCz: {type: 'string'},
383383
titleEn: {type: 'string'},
384384
descriptionCz: {
@@ -394,7 +394,7 @@ export class InstructionStepController {
394394
},
395395
},
396396
link: {type: 'string'},
397-
instructionId: {type: 'number'},
397+
instructionId: {type: 'string'},
398398
},
399399
},
400400
},
@@ -405,7 +405,7 @@ export class InstructionStepController {
405405
},
406406
})
407407
async getPremiumInstructionDetail(
408-
@param.path.number('instructionId') instructionId: number,
408+
@param.path.string('instructionId') instructionId: string,
409409
): Promise<Omit<Step, 'deleteHash'>[]> {
410410
const user = await this.userRepository.findById(this.user.id);
411411
if (!user) {
@@ -438,15 +438,15 @@ export class InstructionStepController {
438438
}
439439

440440
private validateInstructionOwnership(instruction: Instruction): void {
441-
if (Number(instruction.userId) !== Number(this.user.id)) {
441+
if (instruction.userId !== this.user.id) {
442442
throw new HttpErrors.Forbidden(
443443
'You are not authorized to this instruction',
444444
);
445445
}
446446
}
447447

448448
private validateStepOwnership(step: Step, instruction: Instruction): void {
449-
if (Number(step.instructionId) !== Number(instruction.id)) {
449+
if (step.instructionId !== instruction.id) {
450450
throw new HttpErrors.Forbidden(
451451
'You are not authorized to this instruction',
452452
);

src/controllers/user-instruction.controller.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class UserInstructionController {
125125
},
126126
})
127127
async patchInstruction(
128-
@param.path.number('instructionId') instructionId: number,
128+
@param.path.string('instructionId') instructionId: string,
129129
@requestBody({
130130
content: {
131131
'application/json': {
@@ -182,7 +182,7 @@ export class UserInstructionController {
182182
},
183183
})
184184
async deleteInstruction(
185-
@param.path.number('instructionId') instructionId: number,
185+
@param.path.string('instructionId') instructionId: string,
186186
): Promise<boolean> {
187187
const userOriginal = await this.userRepository.findById(this.user.id);
188188
if (!userOriginal) {
@@ -240,7 +240,7 @@ export class UserInstructionController {
240240
instructions: {
241241
type: 'object',
242242
items: {
243-
id: {type: 'number'},
243+
id: {type: 'string'},
244244
titleCz: {type: 'string'},
245245
titleEn: {type: 'string'},
246246
difficulty: {enum: Object.values(Difficulty)},
@@ -252,7 +252,7 @@ export class UserInstructionController {
252252
steps: {
253253
type: 'object',
254254
items: {
255-
id: {type: 'number'},
255+
id: {type: 'string'},
256256
titleCz: {type: 'string'},
257257
titleEn: {type: 'string'},
258258
descriptionCz: {
@@ -330,7 +330,7 @@ export class UserInstructionController {
330330
},
331331
})
332332
async uploadInstructionPicture(
333-
@param.path.number('instructionId') instructionId: number,
333+
@param.path.string('instructionId') instructionId: string,
334334
@requestBody({
335335
content: {
336336
'multipart/form-data': {
@@ -385,7 +385,7 @@ export class UserInstructionController {
385385
},
386386
})
387387
async deleteInstructionPicture(
388-
@param.path.number('instructionId') instructionId: number,
388+
@param.path.string('instructionId') instructionId: string,
389389
): Promise<boolean> {
390390
const user = await this.userRepository.findById(this.user.id);
391391
if (!user) {
@@ -424,7 +424,7 @@ export class UserInstructionController {
424424
},
425425
})
426426
async setPremiumInstruction(
427-
@param.path.number('instructionId') instructionId: number,
427+
@param.path.string('instructionId') instructionId: string,
428428
@requestBody({
429429
content: {
430430
'application/json': {
@@ -495,8 +495,8 @@ export class UserInstructionController {
495495
},
496496
})
497497
async authorizeUserToPremiumInstruction(
498-
@param.path.number('instructionId') instructionId: number,
499-
@param.path.number('userId') userId: number,
498+
@param.path.string('instructionId') instructionId: string,
499+
@param.path.string('userId') userId: string,
500500
@requestBody({
501501
content: {
502502
'application/json': {
@@ -553,19 +553,19 @@ export class UserInstructionController {
553553
instructions: {
554554
type: 'object',
555555
items: {
556-
id: {type: 'number'},
556+
id: {type: 'string'},
557557
titleCz: {type: 'string'},
558558
titleEn: {type: 'string'},
559559
difficulty: {enum: Object.values(Difficulty)},
560560
link: {type: 'string'},
561561
private: {type: 'boolean'},
562562
premium: {type: 'boolean'},
563563
date: {type: 'string'},
564-
userId: {type: 'number'},
564+
userId: {type: 'string'},
565565
steps: {
566566
type: 'object',
567567
items: {
568-
id: {type: 'number'},
568+
id: {type: 'string'},
569569
titleCz: {type: 'string'},
570570
titleEn: {type: 'string'},
571571
descriptionCz: {
@@ -668,15 +668,15 @@ export class UserInstructionController {
668668
instructions: {
669669
type: 'object',
670670
items: {
671-
id: {type: 'number'},
671+
id: {type: 'string'},
672672
titleCz: {type: 'string'},
673673
titleEn: {type: 'string'},
674674
difficulty: {enum: Object.values(Difficulty)},
675675
link: {type: 'string'},
676676
private: {type: 'boolean'},
677677
premium: {type: 'boolean'},
678678
date: {type: 'string'},
679-
userId: {type: 'number'},
679+
userId: {type: 'string'},
680680
},
681681
},
682682
},
@@ -706,7 +706,7 @@ export class UserInstructionController {
706706
}
707707

708708
private validateInstructionOwnership(instruction: Instruction): void {
709-
if (Number(instruction.userId) !== Number(this.user.id)) {
709+
if (instruction.userId !== this.user.id) {
710710
throw new HttpErrors.Forbidden(
711711
'You are not authorized to this instruction',
712712
);

src/controllers/user-link.controller.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class UserLinkController {
3434
},
3535
})
3636
async followUser(
37-
@param.path.number('followeeId') followeeId: number,
37+
@param.path.string('followeeId') followeeId: string,
3838
): Promise<boolean> {
3939
const user = await this.userRepository.findById(this.user.id);
4040
if (!user) {
@@ -67,7 +67,7 @@ export class UserLinkController {
6767
},
6868
})
6969
async unfollowUser(
70-
@param.path.number('followeeId') followeeId: number,
70+
@param.path.string('followeeId') followeeId: string,
7171
): Promise<boolean> {
7272
const user = await this.userRepository.findById(this.user.id);
7373
if (!user) {
@@ -98,7 +98,7 @@ export class UserLinkController {
9898
schema: {
9999
type: 'object',
100100
properties: {
101-
id: {type: 'number'},
101+
id: {type: 'string'},
102102
username: {type: 'string'},
103103
link: {type: 'string'},
104104
},
@@ -109,7 +109,7 @@ export class UserLinkController {
109109
},
110110
})
111111
async getFollowers(
112-
@param.path.number('userId') userId: number,
112+
@param.path.string('userId') userId: string,
113113
@param.query.number('limit') limit: number = 10,
114114
@param.query.number('offset') offset: number = 0,
115115
): Promise<Partial<User[]>> {
@@ -153,7 +153,7 @@ export class UserLinkController {
153153
schema: {
154154
type: 'object',
155155
properties: {
156-
id: {type: 'number'},
156+
id: {type: 'string'},
157157
username: {type: 'string'},
158158
link: {type: 'string'},
159159
},
@@ -164,7 +164,7 @@ export class UserLinkController {
164164
},
165165
})
166166
async getFollowees(
167-
@param.path.number('userId') userId: number,
167+
@param.path.string('userId') userId: string,
168168
@param.query.number('limit') limit: number = 10,
169169
@param.query.number('offset') offset: number = 0,
170170
): Promise<Partial<User[]>> {

src/controllers/user-progress.controller.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ export class UserProgressController {
5656
schema: {
5757
type: 'object',
5858
properties: {
59-
instructionId: {type: 'number'},
60-
stepId: {type: 'number'},
61-
descriptionId: {type: 'number'},
59+
instructionId: {type: 'string'},
60+
stepId: {type: 'string'},
61+
descriptionId: {type: 'string'},
6262
time: {type: 'number'},
6363
},
6464
required: ['instructionId', 'stepId', 'descriptionId', 'time'],
@@ -106,15 +106,15 @@ export class UserProgressController {
106106
},
107107
})
108108
async patchProgress(
109-
@param.path.number('instructionId') instructionId: number,
109+
@param.path.string('instructionId') instructionId: string,
110110
@requestBody({
111111
content: {
112112
'application/json': {
113113
schema: {
114114
type: 'object',
115115
properties: {
116-
stepId: {type: 'number'},
117-
descriptionId: {type: 'number'},
116+
stepId: {type: 'string'},
117+
descriptionId: {type: 'string'},
118118
time: {type: 'number'},
119119
},
120120
},
@@ -157,7 +157,7 @@ export class UserProgressController {
157157
},
158158
})
159159
async deleteProgress(
160-
@param.path.number('instructionId') instructionId: number,
160+
@param.path.string('instructionId') instructionId: string,
161161
): Promise<boolean> {
162162
const userOriginal = await this.userRepository.findById(this.user.id);
163163
if (!userOriginal) {
@@ -187,11 +187,11 @@ export class UserProgressController {
187187
schema: {
188188
type: 'object',
189189
properties: {
190-
id: {type: 'number'},
191-
instructionId: {type: 'number'},
192-
stepId: {type: 'number'},
193-
descriptionId: {type: 'number'},
194-
userId: {type: 'number'},
190+
id: {type: 'string'},
191+
instructionId: {type: 'string'},
192+
stepId: {type: 'string'},
193+
descriptionId: {type: 'string'},
194+
userId: {type: 'string'},
195195
},
196196
},
197197
},
@@ -200,7 +200,7 @@ export class UserProgressController {
200200
},
201201
})
202202
async getProgress(
203-
@param.path.number('instructionId') instructionId: number,
203+
@param.path.string('instructionId') instructionId: string,
204204
): Promise<Progress & ProgressRelations> {
205205
const user = await this.userRepository.findById(this.user.id);
206206
if (!user) {
@@ -219,7 +219,7 @@ export class UserProgressController {
219219
}
220220

221221
private validateProgressOwnership(progress: Progress): void {
222-
if (Number(progress.userId) !== Number(this.user.id)) {
222+
if (progress.userId !== this.user.id) {
223223
throw new HttpErrors.Forbidden('You are not authorized to this progress');
224224
}
225225
}

0 commit comments

Comments
 (0)