-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
107 lines (93 loc) · 2.1 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import 'jsonwebtoken';
import { Knex } from 'knex';
interface Customer {
id: number;
name: string;
email: string;
phone: string;
created_at: string;
}
interface Genre {
id: number;
name: string;
created_at: string;
}
interface Movie {
id: number;
title: string;
genre_id: Genre['id'];
stock: number;
rental_rate: number;
created_at: string;
}
interface TokenPayload {
iat: number;
name: string;
role: 'user' | 'admin';
sub: string;
}
interface Rental {
id: number;
customer_id: Customer['id'];
movie_id: Movie['id'];
created_at: string;
}
interface Return {
id: number;
rental_id: Rental['id'];
fee: number;
created_at: string;
}
interface User {
id: number;
name: string;
email: string;
password: string;
role: 'user' | 'admin';
created_at: string;
}
declare module 'jsonwebtoken' {
export function verify(
token: string,
secretOrPublicKey: Secret,
options?: VerifyOptions
): TokenPayload;
}
declare module 'knex/types/tables' {
interface Tables {
customers: Knex.CompositeTableType<
Customer,
Pick<Customer, 'name' | 'email' | 'phone'> &
Partial<Pick<Customer, 'created_at' | 'is_gold'>>,
Partial<Omit<Customer, 'id'>>
>;
genres: Knex.CompositeTableType<
Genre,
Pick<Genre, 'name'> & Partial<Pick<Genre, 'created_at'>>,
Partial<Omit<Genre, 'id'>>
>;
movies: Knex.CompositeTableType<
Movie,
Pick<Movie, 'title' | 'genre_id' | 'stock' | 'rental_rate'> &
Partial<Pick<Movie, 'created_at'>>,
Partial<Omit<Movie, 'id'>>
>;
rentals: Knex.CompositeTableType<
Rental,
Pick<Rental, 'customer_id' | 'movie_id'> &
Partial<Pick<Rental, 'created_at'>>,
Partial<Omit<Rental, 'id'>>
>;
returns: Knex.CompositeTableType<
Return,
Pick<Return, 'rental_id' | 'fee'> & Partial<Pick<Return, 'created_at'>>,
Partial<Omit<Return, 'id'>>
>;
users: Knex.CompositeTableType<
User,
Pick<User, 'name' | 'email' | 'password'> &
Partial<Pick<User, 'created_at'>>,
Partial<Omit<User, 'id'>>
>;
}
}