meet-my-ride 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +1 -1
- package/dist/users/user.service.d.ts +17 -8
- package/dist/users/user.service.js +50 -33
- package/dist/users/user.types.d.ts +47 -0
- package/dist/users/user.types.js +3 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
+
import { UserLogin, UserRegister, User, UserUpdate, UserRefreshResponse, AuthResponse, UserRegisterResponse, VerifyEmailResponse } from "./user.types";
|
|
2
3
|
export declare class UserService {
|
|
3
4
|
private http;
|
|
4
5
|
private updateToken;
|
|
5
6
|
constructor(http: AxiosInstance, updateToken: (token: string) => void);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
/** GET /api/Users */
|
|
8
|
+
getAll(): Promise<User[]>;
|
|
9
|
+
/** GET /api/Users/{userId} */
|
|
10
|
+
getById(userId: string): Promise<User>;
|
|
11
|
+
/** PUT /api/Users/{userId} */
|
|
12
|
+
update(userId: string, data: UserUpdate): Promise<User>;
|
|
13
|
+
/** DELETE /api/Users/{userId} */
|
|
14
|
+
delete(userId: string): Promise<void>;
|
|
15
|
+
/** POST /api/Users/register */
|
|
16
|
+
register(data: UserRegister): Promise<UserRegisterResponse>;
|
|
17
|
+
/** POST /api/Users/login */
|
|
18
|
+
login(data: UserLogin): Promise<AuthResponse>;
|
|
19
|
+
/** POST /api/Users/refresh */
|
|
20
|
+
refresh(refreshToken: string): Promise<UserRefreshResponse>;
|
|
21
|
+
/** POST /api/Users/verify-email */
|
|
22
|
+
verifyEmail(userId: string, token: string): Promise<VerifyEmailResponse>;
|
|
14
23
|
}
|
|
@@ -6,41 +6,58 @@ class UserService {
|
|
|
6
6
|
this.http = http;
|
|
7
7
|
this.updateToken = updateToken;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
/** GET /api/Users */
|
|
10
|
+
async getAll() {
|
|
11
|
+
const response = await this.http.get("/api/Users");
|
|
12
|
+
return response.data;
|
|
13
|
+
}
|
|
14
|
+
/** GET /api/Users/{userId} */
|
|
15
|
+
async getById(userId) {
|
|
16
|
+
const response = await this.http.get(`/api/Users/${userId}`);
|
|
17
|
+
return response.data;
|
|
18
|
+
}
|
|
19
|
+
/** PUT /api/Users/{userId} */
|
|
20
|
+
async update(userId, data) {
|
|
21
|
+
const response = await this.http.put(`/api/Users/${userId}`, data);
|
|
22
|
+
return response.data;
|
|
23
|
+
}
|
|
24
|
+
/** DELETE /api/Users/{userId} */
|
|
25
|
+
async delete(userId) {
|
|
26
|
+
await this.http.delete(`/api/Users/${userId}`);
|
|
27
|
+
}
|
|
28
|
+
/** POST /api/Users/register */
|
|
29
|
+
async register(data) {
|
|
30
|
+
const response = await this.http.post("/api/Users/register", data);
|
|
31
|
+
return response.data;
|
|
32
|
+
}
|
|
33
|
+
/** POST /api/Users/login */
|
|
34
|
+
async login(data) {
|
|
35
|
+
const response = await this.http.post("/api/Users/login", data);
|
|
36
|
+
const resData = response.data;
|
|
37
|
+
// Only update token if it exists
|
|
38
|
+
if (resData.accessToken) {
|
|
39
|
+
this.updateToken(resData.accessToken);
|
|
40
|
+
}
|
|
41
|
+
return resData;
|
|
42
|
+
}
|
|
43
|
+
/** POST /api/Users/refresh */
|
|
44
|
+
async refresh(refreshToken) {
|
|
45
|
+
const response = await this.http.post("/api/Users/refresh", {
|
|
46
|
+
refreshToken
|
|
31
47
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
const resData = response.data;
|
|
49
|
+
if (resData.accessToken) {
|
|
50
|
+
this.updateToken(resData.accessToken);
|
|
51
|
+
}
|
|
52
|
+
return resData;
|
|
53
|
+
}
|
|
54
|
+
/** POST /api/Users/verify-email */
|
|
55
|
+
async verifyEmail(userId, token) {
|
|
56
|
+
const response = await this.http.post("/api/Users/verifyEmail", {
|
|
57
|
+
userId,
|
|
58
|
+
token
|
|
40
59
|
});
|
|
41
|
-
|
|
42
|
-
verifyEmail(code) {
|
|
43
|
-
return this.http.post("/api/Users/verify-email", { code }).then(r => r.data);
|
|
60
|
+
return response.data;
|
|
44
61
|
}
|
|
45
62
|
}
|
|
46
63
|
exports.UserService = UserService;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface User {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
emailVerified?: string;
|
|
5
|
+
firstName: string;
|
|
6
|
+
lastName: string;
|
|
7
|
+
username: string;
|
|
8
|
+
}
|
|
9
|
+
export interface UserLogin {
|
|
10
|
+
email: string;
|
|
11
|
+
password: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AuthResponse {
|
|
14
|
+
user: User;
|
|
15
|
+
accessToken?: string;
|
|
16
|
+
refreshToken?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface UserRegister {
|
|
19
|
+
email: string;
|
|
20
|
+
password: string;
|
|
21
|
+
firstName: string;
|
|
22
|
+
lastName: string;
|
|
23
|
+
username: string;
|
|
24
|
+
}
|
|
25
|
+
export interface UserRegisterResponse {
|
|
26
|
+
id: string;
|
|
27
|
+
username: string;
|
|
28
|
+
firstName: string;
|
|
29
|
+
lastName: string;
|
|
30
|
+
email: string;
|
|
31
|
+
}
|
|
32
|
+
export interface UserUpdate {
|
|
33
|
+
email?: string;
|
|
34
|
+
firstName?: string;
|
|
35
|
+
lastName?: string;
|
|
36
|
+
password?: string;
|
|
37
|
+
username?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface UserRefreshResponse {
|
|
40
|
+
accessToken: string;
|
|
41
|
+
refreshToken?: string;
|
|
42
|
+
expiresIn?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface VerifyEmailResponse {
|
|
45
|
+
message: string;
|
|
46
|
+
isVerified: boolean;
|
|
47
|
+
}
|