feat: Add instructor registration endpoint and rename student registration to learner registration.

This commit is contained in:
JakkrapartXD 2026-01-19 07:30:28 +00:00
parent e379ed83c8
commit a38389cc9f
2 changed files with 122 additions and 1 deletions

View file

@ -67,13 +67,61 @@ export class AuthController {
return await this.authService.login(body);
}
/**
* User registration
* @summary Register a new instructor account
* @param body Registration data
* @returns Created user information
*/
@Post('register-instructor')
@SuccessResponse('201', 'Registration successful')
@Response('400', 'Validation error')
@Response('409', 'Username or email already exists')
@Example<RegisterResponse>({
user: {
id: 4,
username: 'newinstructor',
email: 'instructor@example.com',
updated_at: new Date('2024-01-01T00:00:00Z'),
created_at: new Date('2024-01-01T00:00:00Z'),
role: {
code: 'INSTRUCTOR',
name: {
th: 'ผู้สอน',
en: 'Instructor'
}
},
profile: {
prefix: {
th: 'นาย',
en: 'Mr.'
},
first_name: 'John',
last_name: 'Doe',
phone: null,
avatar_url: null,
birth_date: null
}
},
message: 'Registration successful'
})
public async registerInstructor(@Body() body: RegisterRequest): Promise<RegisterResponse> {
// Validate input
const { error } = registerSchema.validate(body);
if (error) {
throw new ValidationError(error.details[0].message);
}
return await this.authService.registerInstructor(body);
}
/**
* User registration
* @summary Register a new student account
* @param body Registration data
* @returns Created user information
*/
@Post('register')
@Post('register-learner')
@SuccessResponse('201', 'Registration successful')
@Response('400', 'Validation error')
@Response('409', 'Username or email already exists')