mielk-api 1.0.6 → 1.0.8

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.
@@ -1,11 +1,12 @@
1
- import { Msg } from "../../internal/messaging/errorMessages.js";
1
+ import { Msg } from "../../internal/messaging/messageTags.js";
2
2
  const createApiStatus = (success, code, defaultMessageTag) => ({ success, code, defaultMessageTag });
3
+ const msg = Msg.ApiStatus;
3
4
  export const API_STATUS = {
4
- OK: createApiStatus(true, 200, Msg.ApiStatus.ok),
5
- CREATED: createApiStatus(true, 201, Msg.ApiStatus.created),
6
- BAD_REQUEST: createApiStatus(false, 400, Msg.ApiStatus.badRequest),
7
- UNAUTHORIZED: createApiStatus(false, 401, Msg.ApiStatus.unauthorized),
8
- NOT_FOUND: createApiStatus(false, 404, Msg.ApiStatus.notFound),
9
- CONFLICT: createApiStatus(false, 409, Msg.ApiStatus.conflict),
10
- SERVER_ERROR: createApiStatus(false, 500, Msg.ApiStatus.serverError),
5
+ OK: createApiStatus(true, 200, msg.ok),
6
+ CREATED: createApiStatus(true, 201, msg.created),
7
+ BAD_REQUEST: createApiStatus(false, 400, msg.badRequest),
8
+ UNAUTHORIZED: createApiStatus(false, 401, msg.unauthorized),
9
+ NOT_FOUND: createApiStatus(false, 404, msg.notFound),
10
+ CONFLICT: createApiStatus(false, 409, msg.conflict),
11
+ SERVER_ERROR: createApiStatus(false, 500, msg.serverError),
11
12
  };
@@ -1,4 +1,4 @@
1
1
  import { ApiSuccess, ApiError } from './types.js';
2
- import type { ApiResponse } from './types.js';
2
+ import type { ApiResponse, ApiErrorDetails } from './types.js';
3
3
  export { ApiError, ApiSuccess };
4
- export type { ApiResponse };
4
+ export type { ApiResponse, ApiErrorDetails };
@@ -4,6 +4,10 @@ export interface ApiSuccess<T> {
4
4
  }
5
5
  export interface ApiError {
6
6
  success: false;
7
- error: string;
7
+ details: ApiErrorDetails;
8
8
  }
9
9
  export type ApiResponse<T> = ApiSuccess<T> | ApiError;
10
+ export type ApiErrorDetails = {
11
+ message: string;
12
+ params?: (string | number | Date | unknown | boolean)[];
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mielk-api",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "keywords": [],
5
5
  "author": "mielk",
6
6
  "description": "Wrapper for API operations",
@@ -56,6 +56,6 @@
56
56
  "dist"
57
57
  ],
58
58
  "dependencies": {
59
- "mielk-fn": "^1.1.0"
59
+ "mielk-fn": "^1.1.1"
60
60
  }
61
61
  }