mielk-api 1.0.5 → 1.0.7
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/back/enums/ApiStatus.d.ts +2 -1
- package/dist/back/enums/ApiStatus.js +10 -9
- package/dist/back/enums/PostgreErrorCodes.d.ts +1 -1
- package/dist/back/enums/PostgreErrorCodes.js +1 -1
- package/dist/back/index.d.ts +4 -4
- package/dist/back/index.js +4 -4
- package/dist/front/types.d.ts +5 -1
- package/dist/internal/messaging/messageTags.d.ts +11 -0
- package/dist/internal/messaging/messageTags.js +13 -0
- package/package.json +2 -2
- package/dist/internal/messaging/Msg.d.ts +0 -10
- package/dist/internal/messaging/Msg.js +0 -5
- package/dist/internal/messaging/apiStatusTags.d.ts +0 -8
- package/dist/internal/messaging/apiStatusTags.js +0 -10
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ApiStatus } from "../types/types.js";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const API_STATUS: {
|
|
3
3
|
OK: ApiStatus;
|
|
4
4
|
CREATED: ApiStatus;
|
|
5
5
|
BAD_REQUEST: ApiStatus;
|
|
6
|
+
UNAUTHORIZED: ApiStatus;
|
|
6
7
|
NOT_FOUND: ApiStatus;
|
|
7
8
|
CONFLICT: ApiStatus;
|
|
8
9
|
SERVER_ERROR: ApiStatus;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Msg } from "../../internal/messaging/Msg.js";
|
|
1
|
+
import { Msg } from "../../internal/messaging/messageTags.js";
|
|
3
2
|
const createApiStatus = (success, code, defaultMessageTag) => ({ success, code, defaultMessageTag });
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const msg = Msg.ApiStatus;
|
|
4
|
+
export const API_STATUS = {
|
|
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
|
};
|
package/dist/back/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ApiStatus } from './types/types.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { PG_ERRORS } from './enums/PostgreErrorCodes.js';
|
|
3
|
+
import { API_STATUS } from './enums/ApiStatus.js';
|
|
4
4
|
export type { ApiStatus };
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
5
|
+
export { PG_ERRORS };
|
|
6
|
+
export { API_STATUS };
|
package/dist/back/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
import { PG_ERRORS } from './enums/PostgreErrorCodes.js';
|
|
2
|
+
import { API_STATUS } from './enums/ApiStatus.js';
|
|
3
|
+
export { PG_ERRORS };
|
|
4
|
+
export { API_STATUS };
|
package/dist/front/types.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ export interface ApiSuccess<T> {
|
|
|
4
4
|
}
|
|
5
5
|
export interface ApiError {
|
|
6
6
|
success: false;
|
|
7
|
-
|
|
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
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const PARENT_FOLDER = 'api/';
|
|
2
|
+
const API_STATUS_FOLDER = `${PARENT_FOLDER}/ApiStatus`;
|
|
3
|
+
export const Msg = {
|
|
4
|
+
ApiStatus: {
|
|
5
|
+
ok: `${API_STATUS_FOLDER}:ok`,
|
|
6
|
+
created: `${API_STATUS_FOLDER}:created`,
|
|
7
|
+
unauthorized: `${API_STATUS_FOLDER}:unauthorized`,
|
|
8
|
+
badRequest: `${API_STATUS_FOLDER}:badRequest`,
|
|
9
|
+
notFound: `${API_STATUS_FOLDER}:notFound`,
|
|
10
|
+
conflict: `${API_STATUS_FOLDER}:conflict`,
|
|
11
|
+
serverError: `${API_STATUS_FOLDER}:serverError`,
|
|
12
|
+
}
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mielk-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
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.
|
|
59
|
+
"mielk-fn": "^1.1.1"
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const Msg: {
|
|
2
|
-
API_STATUS: {
|
|
3
|
-
OK: import("mielk-fn/tags").Tag;
|
|
4
|
-
CREATED: import("mielk-fn/tags").Tag;
|
|
5
|
-
BAD_REQUEST: import("mielk-fn/tags").Tag;
|
|
6
|
-
NOT_FOUND: import("mielk-fn/tags").Tag;
|
|
7
|
-
CONFLICT: import("mielk-fn/tags").Tag;
|
|
8
|
-
SERVER_ERROR: import("mielk-fn/tags").Tag;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const ApiStatusMessageTags: (parentPrefix: string) => {
|
|
2
|
-
OK: import("mielk-fn/tags").Tag;
|
|
3
|
-
CREATED: import("mielk-fn/tags").Tag;
|
|
4
|
-
BAD_REQUEST: import("mielk-fn/tags").Tag;
|
|
5
|
-
NOT_FOUND: import("mielk-fn/tags").Tag;
|
|
6
|
-
CONFLICT: import("mielk-fn/tags").Tag;
|
|
7
|
-
SERVER_ERROR: import("mielk-fn/tags").Tag;
|
|
8
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createTag } from 'mielk-fn/tags';
|
|
2
|
-
const prefix = 'ApiStatus';
|
|
3
|
-
export const ApiStatusMessageTags = (parentPrefix) => ({
|
|
4
|
-
OK: createTag(parentPrefix, prefix, 'ok'),
|
|
5
|
-
CREATED: createTag(parentPrefix, prefix, 'created'),
|
|
6
|
-
BAD_REQUEST: createTag(parentPrefix, prefix, 'badRequest'),
|
|
7
|
-
NOT_FOUND: createTag(parentPrefix, prefix, 'notFound'),
|
|
8
|
-
CONFLICT: createTag(parentPrefix, prefix, 'conflict'),
|
|
9
|
-
SERVER_ERROR: createTag(parentPrefix, prefix, 'serverError'),
|
|
10
|
-
});
|