53 lines
933 B
TypeScript
53 lines
933 B
TypeScript
export interface User {
|
|
id: number;
|
|
name: string;
|
|
email: string;
|
|
createdAt: Date;
|
|
}
|
|
|
|
export interface Admin extends User {
|
|
permissions: string[];
|
|
role: 'admin' | 'superadmin';
|
|
}
|
|
|
|
export type UserId = number | string;
|
|
|
|
export type AdminResponse = {
|
|
user: Admin;
|
|
token: string;
|
|
};
|
|
|
|
export type ApiResponse<T> = {
|
|
data: T;
|
|
status: number;
|
|
message: string;
|
|
};
|
|
|
|
export interface Session {
|
|
id: string;
|
|
userId: UserId;
|
|
expiresAt: Date;
|
|
}
|
|
|
|
export enum Status {
|
|
Pending = 'pending',
|
|
Active = 'active',
|
|
Inactive = 'inactive'
|
|
}
|
|
|
|
export type ComplexType = {
|
|
nested: {
|
|
deep: {
|
|
value: string;
|
|
};
|
|
};
|
|
union: 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
|
|
intersection: User & { extra: string };
|
|
};
|
|
|
|
export type ConditionalType<T> = T extends string ? 'string' : T extends number ? 'number' : 'unknown';
|
|
|
|
export type DeepPartial<T> = {
|
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
};
|