migration to typescript
This commit is contained in:
parent
924000b084
commit
9fde77468a
41 changed files with 11952 additions and 10164 deletions
62
Backend/src/types/auth.types.ts
Normal file
62
Backend/src/types/auth.types.ts
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* Authentication Request/Response Types
|
||||
*/
|
||||
|
||||
export interface LoginRequest {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface RegisterRequest {
|
||||
username: string;
|
||||
email: string;
|
||||
password: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
prefix?: {
|
||||
th?: string;
|
||||
en?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface LoginResponse {
|
||||
token: string;
|
||||
refreshToken: string;
|
||||
user: UserResponse;
|
||||
}
|
||||
|
||||
export interface RegisterResponse {
|
||||
user: UserResponse;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface RefreshTokenRequest {
|
||||
refreshToken: string;
|
||||
}
|
||||
|
||||
export interface RefreshTokenResponse {
|
||||
token: string;
|
||||
refreshToken: string;
|
||||
}
|
||||
|
||||
export interface UserResponse {
|
||||
id: number;
|
||||
username: string;
|
||||
email: string;
|
||||
role: {
|
||||
code: string;
|
||||
name: {
|
||||
th: string;
|
||||
en: string;
|
||||
};
|
||||
};
|
||||
profile?: {
|
||||
prefix?: {
|
||||
th?: string;
|
||||
en?: string;
|
||||
};
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
avatar_url?: string;
|
||||
};
|
||||
}
|
||||
58
Backend/src/types/index.ts
Normal file
58
Backend/src/types/index.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
export interface MultiLanguageText {
|
||||
th: string;
|
||||
en: string;
|
||||
}
|
||||
|
||||
export interface JWTPayload {
|
||||
id: number;
|
||||
username: string;
|
||||
email: string;
|
||||
roleCode: string;
|
||||
}
|
||||
|
||||
export interface AuthRequest extends Request {
|
||||
user?: JWTPayload;
|
||||
}
|
||||
|
||||
export interface PaginationParams {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export interface PaginatedResponse<T> {
|
||||
data: T[];
|
||||
pagination: {
|
||||
page: number;
|
||||
limit: number;
|
||||
total: number;
|
||||
totalPages: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ErrorResponse {
|
||||
error: {
|
||||
code: string;
|
||||
message: string;
|
||||
details?: any[];
|
||||
};
|
||||
}
|
||||
|
||||
export enum CourseStatus {
|
||||
DRAFT = 'DRAFT',
|
||||
PENDING = 'PENDING',
|
||||
APPROVED = 'APPROVED',
|
||||
REJECTED = 'REJECTED'
|
||||
}
|
||||
|
||||
export enum LessonType {
|
||||
VIDEO = 'VIDEO',
|
||||
TEXT = 'TEXT',
|
||||
PDF = 'PDF',
|
||||
QUIZ = 'QUIZ'
|
||||
}
|
||||
|
||||
export enum QuizScorePolicy {
|
||||
HIGHEST = 'HIGHEST',
|
||||
LATEST = 'LATEST',
|
||||
AVERAGE = 'AVERAGE'
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue