meet-my-ride 1.0.1 → 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
@@ -1,11 +1,12 @@
1
+ import { UserService } from "./users";
1
2
  export declare class MeetMyRideClient {
2
3
  private baseUrl;
3
4
  private apiKey?;
4
- private http;
5
+ private readonly http;
6
+ user: UserService;
5
7
  constructor(baseUrl: string, apiKey?: string | undefined);
6
- getUsers(): Promise<any>;
7
- getUser(id: string): Promise<any>;
8
- createUser(user: any): Promise<any>;
9
- updateUser(id: string, user: any): Promise<any>;
10
- deleteUser(id: string): Promise<any>;
8
+ /**
9
+ * Allow services (like login/refresh) to update the Authorization header.
10
+ */
11
+ private setToken;
11
12
  }
package/dist/client.js CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MeetMyRideClient = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
+ const users_1 = require("./users");
8
9
  class MeetMyRideClient {
9
10
  constructor(baseUrl, apiKey) {
10
11
  this.baseUrl = baseUrl;
@@ -16,31 +17,14 @@ class MeetMyRideClient {
16
17
  ...(apiKey ? { "Authorization": `Bearer ${apiKey}` } : {})
17
18
  }
18
19
  });
20
+ // Initialize modules/services
21
+ this.user = new users_1.UserService(this.http, this.setToken.bind(this));
19
22
  }
20
- /* Example GET endpoint */
21
- async getUsers() {
22
- const response = await this.http.get("/users");
23
- return response.data;
24
- }
25
- /* Example GET by ID */
26
- async getUser(id) {
27
- const response = await this.http.get(`/users/${id}`);
28
- return response.data;
29
- }
30
- /* Example POST */
31
- async createUser(user) {
32
- const response = await this.http.post("/users", user);
33
- return response.data;
34
- }
35
- /* Example PUT */
36
- async updateUser(id, user) {
37
- const response = await this.http.put(`/users/${id}`, user);
38
- return response.data;
39
- }
40
- /* Example DELETE */
41
- async deleteUser(id) {
42
- const response = await this.http.delete(`/users/${id}`);
43
- return response.data;
23
+ /**
24
+ * Allow services (like login/refresh) to update the Authorization header.
25
+ */
26
+ setToken(token) {
27
+ this.http.defaults.headers["Authorization"] = `Bearer ${token}`;
44
28
  }
45
29
  }
46
30
  exports.MeetMyRideClient = MeetMyRideClient;
@@ -0,0 +1 @@
1
+ export * from "./user.service";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./user.service"), exports);
@@ -0,0 +1,23 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { UserLogin, UserLoginResponse, UserRegister, User, UserUpdate, UserRefreshResponse } from "./user.types";
3
+ export declare class UserService {
4
+ private http;
5
+ private updateToken;
6
+ constructor(http: AxiosInstance, updateToken: (token: string) => void);
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>;
23
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserService = void 0;
4
+ class UserService {
5
+ constructor(http, updateToken) {
6
+ this.http = http;
7
+ this.updateToken = updateToken;
8
+ }
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
46
+ });
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 });
56
+ }
57
+ }
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.1",
3
+ "version": "1.0.4",
4
4
  "description": "Private library for the MeetMyRide applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,23 +8,21 @@
8
8
  },
9
9
  "license": "ISC",
10
10
  "author": "MightyMitta",
11
-
12
11
  "main": "dist/index.js",
13
12
  "types": "dist/index.d.ts",
14
-
15
13
  "files": [
16
14
  "dist"
17
15
  ],
18
-
19
16
  "scripts": {
20
17
  "build": "tsc",
18
+ "publish:patch": "npm version patch && npm run build && npm publish",
19
+ "publish:minor": "npm version minor && npm run build && npm publish",
20
+ "publish:major": "npm version major && npm run build && npm publish",
21
21
  "test": "echo \"Error: no test specified\" && exit 1"
22
22
  },
23
-
24
23
  "dependencies": {
25
24
  "axios": "^1.13.2"
26
25
  },
27
-
28
26
  "devDependencies": {
29
27
  "@types/node": "^24.10.1",
30
28
  "ts-node": "^10.9.2",