meet-my-ride 1.0.3 → 1.0.4

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 CHANGED
@@ -2,7 +2,7 @@ import { UserService } from "./users";
2
2
  export declare class MeetMyRideClient {
3
3
  private baseUrl;
4
4
  private apiKey?;
5
- private http;
5
+ private readonly http;
6
6
  user: UserService;
7
7
  constructor(baseUrl: string, apiKey?: string | undefined);
8
8
  /**
@@ -1,14 +1,23 @@
1
1
  import { AxiosInstance } from "axios";
2
+ import { UserLogin, UserLoginResponse, UserRegister, User, UserUpdate, UserRefreshResponse } 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
- getAll(): Promise<any>;
7
- getById(userId: string): Promise<any>;
8
- update(userId: string, data: any): Promise<any>;
9
- delete(userId: string): Promise<any>;
10
- register(data: any): Promise<any>;
11
- login(data: any): Promise<any>;
12
- refresh(refreshToken: string): Promise<any>;
13
- verifyEmail(code: string): Promise<any>;
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<UserLoginResponse>;
17
+ /** POST /api/Users/login */
18
+ login(data: UserLogin): Promise<UserLoginResponse>;
19
+ /** POST /api/Users/refresh */
20
+ refresh(refreshToken: string): Promise<UserRefreshResponse>;
21
+ /** POST /api/Users/verify-email */
22
+ verifyEmail(code: string): Promise<void>;
14
23
  }
@@ -6,41 +6,53 @@ class UserService {
6
6
  this.http = http;
7
7
  this.updateToken = updateToken;
8
8
  }
9
- getAll() {
10
- return this.http.get("/api/Users").then(r => r.data);
11
- }
12
- getById(userId) {
13
- return this.http.get(`/api/Users/${userId}`).then(r => r.data);
14
- }
15
- update(userId, data) {
16
- return this.http.put(`/api/Users/${userId}`, data).then(r => r.data);
17
- }
18
- delete(userId) {
19
- return this.http.delete(`/api/Users/${userId}`).then(r => r.data);
20
- }
21
- register(data) {
22
- return this.http.post("/api/Users/register", data).then(r => r.data);
23
- }
24
- login(data) {
25
- return this.http.post("/api/Users/login", data).then(response => {
26
- var _a;
27
- if ((_a = response.data) === null || _a === void 0 ? void 0 : _a.token) {
28
- this.updateToken(response.data.token);
29
- }
30
- return response.data;
31
- });
32
- }
33
- refresh(refreshToken) {
34
- return this.http.post("/api/Users/refresh", { refreshToken }).then(r => {
35
- var _a;
36
- if ((_a = r.data) === null || _a === void 0 ? void 0 : _a.token) {
37
- this.updateToken(r.data.token);
38
- }
39
- return r.data;
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
+ if (resData.token) {
38
+ this.updateToken(resData.token);
39
+ }
40
+ return resData;
41
+ }
42
+ /** POST /api/Users/refresh */
43
+ async refresh(refreshToken) {
44
+ const response = await this.http.post("/api/Users/refresh", {
45
+ refreshToken
40
46
  });
41
- }
42
- verifyEmail(code) {
43
- return this.http.post("/api/Users/verify-email", { code }).then(r => r.data);
47
+ const resData = response.data;
48
+ if (resData.token) {
49
+ this.updateToken(resData.token);
50
+ }
51
+ return resData;
52
+ }
53
+ /** POST /api/Users/verify-email */
54
+ async verifyEmail(code) {
55
+ await this.http.post("/api/Users/verify-email", { code });
44
56
  }
45
57
  }
46
58
  exports.UserService = UserService;
@@ -0,0 +1,33 @@
1
+ export interface User {
2
+ id: string;
3
+ email: string;
4
+ firstName: string;
5
+ lastName: string;
6
+ }
7
+ export interface UserLogin {
8
+ email: string;
9
+ password: string;
10
+ }
11
+ export interface UserLoginResponse {
12
+ token: string;
13
+ refreshToken?: string;
14
+ userId?: string;
15
+ expiresIn?: number;
16
+ }
17
+ export interface UserRegister {
18
+ email: string;
19
+ password: string;
20
+ firstName: string;
21
+ lastName: string;
22
+ }
23
+ export interface UserUpdate {
24
+ email?: string;
25
+ firstName?: string;
26
+ lastName?: string;
27
+ password?: string;
28
+ }
29
+ export interface UserRefreshResponse {
30
+ token: string;
31
+ refreshToken?: string;
32
+ expiresIn?: number;
33
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meet-my-ride",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Private library for the MeetMyRide applications",
5
5
  "repository": {
6
6
  "type": "git",