@mustafahmed1997/learnify-backend 1.1.0 → 1.3.0
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/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/getErrorMsg.d.ts +1 -0
- package/dist/utils/getErrorMsg.js +4 -0
- package/dist/utils/getErrorMsg.js.map +1 -0
- package/dist/utils/getJsonResponse.d.ts +12 -0
- package/dist/utils/getJsonResponse.js +13 -0
- package/dist/utils/getJsonResponse.js.map +1 -0
- package/dist/utils/getSuccessMsg.d.ts +1 -0
- package/dist/utils/getSuccessMsg.js +4 -0
- package/dist/utils/getSuccessMsg.js.map +1 -0
- package/dist/utils/validationErrorMessages.d.ts +11 -0
- package/dist/utils/validationErrorMessages.js +34 -0
- package/dist/utils/validationErrorMessages.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,9 @@ export type { Role } from "./constants/validRoles.js";
|
|
|
7
7
|
export { AppError } from "./errors/AppError.js";
|
|
8
8
|
export { globalErrorHandler } from "./errors/globalErrorHandler.js";
|
|
9
9
|
export { handlePrismaError } from "./errors/handlePrismaError.js";
|
|
10
|
+
export { getErrorMsg } from "./utils/getErrorMsg.js";
|
|
11
|
+
export { getSuccessMsg } from "./utils/getSuccessMsg.js";
|
|
12
|
+
export { getJsonResponse } from "./utils/getJsonResponse.js";
|
|
13
|
+
export type { JsonResponseOptions } from "./utils/getJsonResponse.js";
|
|
14
|
+
export { requiredFieldMsg, minLengthMsg, maxLengthMsg, invalidSchemaFormatMsg, invalidEmailMsg, invalidPasswordMsg, invalidDateFormatMsg, futureDateRequiredMsg, invalidNumberMsg, positiveNumberMsg, invalidUrlMsg, } from "./utils/validationErrorMessages.js";
|
|
10
15
|
export type { ClerkUser } from "./types/ClerkUser.js";
|
package/dist/index.js
CHANGED
|
@@ -6,4 +6,8 @@ export { validRoles } from "./constants/validRoles.js";
|
|
|
6
6
|
export { AppError } from "./errors/AppError.js";
|
|
7
7
|
export { globalErrorHandler } from "./errors/globalErrorHandler.js";
|
|
8
8
|
export { handlePrismaError } from "./errors/handlePrismaError.js";
|
|
9
|
+
export { getErrorMsg } from "./utils/getErrorMsg.js";
|
|
10
|
+
export { getSuccessMsg } from "./utils/getSuccessMsg.js";
|
|
11
|
+
export { getJsonResponse } from "./utils/getJsonResponse.js";
|
|
12
|
+
export { requiredFieldMsg, minLengthMsg, maxLengthMsg, invalidSchemaFormatMsg, invalidEmailMsg, invalidPasswordMsg, invalidDateFormatMsg, futureDateRequiredMsg, invalidNumberMsg, positiveNumberMsg, invalidUrlMsg, } from "./utils/validationErrorMessages.js";
|
|
9
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,GACd,MAAM,oCAAoC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getErrorMsg(resource: string, verb: "was" | "were", message: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getErrorMsg.js","sourceRoot":"","sources":["../../src/utils/getErrorMsg.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,IAAoB,EACpB,OAAe;IAEf,OAAO,GAAG,QAAQ,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type JsonResponseOptions<TData = unknown, TAdditionalInfo = unknown> = {
|
|
2
|
+
message?: string;
|
|
3
|
+
data?: TData;
|
|
4
|
+
additionalInfo?: TAdditionalInfo;
|
|
5
|
+
error?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function getJsonResponse<TData = unknown, TAdditionalInfo = unknown>({ message, data, additionalInfo, error, }: JsonResponseOptions<TData, TAdditionalInfo>): {
|
|
8
|
+
message?: string;
|
|
9
|
+
data?: TData;
|
|
10
|
+
additionalInfo?: TAdditionalInfo;
|
|
11
|
+
error?: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function getJsonResponse({ message, data, additionalInfo, error, }) {
|
|
2
|
+
const response = {};
|
|
3
|
+
if (message !== undefined)
|
|
4
|
+
response.message = message;
|
|
5
|
+
if (data !== undefined)
|
|
6
|
+
response.data = data;
|
|
7
|
+
if (additionalInfo !== undefined)
|
|
8
|
+
response.additionalInfo = additionalInfo;
|
|
9
|
+
if (error !== undefined)
|
|
10
|
+
response.error = error;
|
|
11
|
+
return response;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=getJsonResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getJsonResponse.js","sourceRoot":"","sources":["../../src/utils/getJsonResponse.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,eAAe,CAA6C,EAC1E,OAAO,EACP,IAAI,EACJ,cAAc,EACd,KAAK,GACuC;IAC5C,MAAM,QAAQ,GAKV,EAAE,CAAC;IAEP,IAAI,OAAO,KAAK,SAAS;QAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;IACtD,IAAI,IAAI,KAAK,SAAS;QAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;IAC7C,IAAI,cAAc,KAAK,SAAS;QAAE,QAAQ,CAAC,cAAc,GAAG,cAAc,CAAC;IAC3E,IAAI,KAAK,KAAK,SAAS;QAAE,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;IAEhD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSuccessMsg(resource: string, verb: "has" | "have", action: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSuccessMsg.js","sourceRoot":"","sources":["../../src/utils/getSuccessMsg.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAC3B,QAAgB,EAChB,IAAoB,EACpB,MAAc;IAEd,OAAO,GAAG,QAAQ,IAAI,IAAI,SAAS,MAAM,eAAe,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function requiredFieldMsg(field: string): string;
|
|
2
|
+
export declare function minLengthMsg(minLength: number): string;
|
|
3
|
+
export declare function maxLengthMsg(maxLength: number): string;
|
|
4
|
+
export declare function invalidSchemaFormatMsg(field: string, format: string): string;
|
|
5
|
+
export declare function invalidEmailMsg(): string;
|
|
6
|
+
export declare function invalidPasswordMsg(): string;
|
|
7
|
+
export declare function invalidNumberMsg(field: string): string;
|
|
8
|
+
export declare function positiveNumberMsg(field: string): string;
|
|
9
|
+
export declare function invalidUrlMsg(): string;
|
|
10
|
+
export declare function invalidDateFormatMsg(): string;
|
|
11
|
+
export declare function futureDateRequiredMsg(): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function requiredFieldMsg(field) {
|
|
2
|
+
return `${field} is required`;
|
|
3
|
+
}
|
|
4
|
+
export function minLengthMsg(minLength) {
|
|
5
|
+
return `Minimum length is ${minLength}`;
|
|
6
|
+
}
|
|
7
|
+
export function maxLengthMsg(maxLength) {
|
|
8
|
+
return `Maximum length is ${maxLength}`;
|
|
9
|
+
}
|
|
10
|
+
export function invalidSchemaFormatMsg(field, format) {
|
|
11
|
+
return `${field} should match format: ${format}`;
|
|
12
|
+
}
|
|
13
|
+
export function invalidEmailMsg() {
|
|
14
|
+
return "Invalid email format";
|
|
15
|
+
}
|
|
16
|
+
export function invalidPasswordMsg() {
|
|
17
|
+
return "Password should be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, one number, and one special character";
|
|
18
|
+
}
|
|
19
|
+
export function invalidNumberMsg(field) {
|
|
20
|
+
return `Invalid number format for field: ${field}`;
|
|
21
|
+
}
|
|
22
|
+
export function positiveNumberMsg(field) {
|
|
23
|
+
return `${field} should be positive`;
|
|
24
|
+
}
|
|
25
|
+
export function invalidUrlMsg() {
|
|
26
|
+
return "Invalid URL";
|
|
27
|
+
}
|
|
28
|
+
export function invalidDateFormatMsg() {
|
|
29
|
+
return "Invalid date format";
|
|
30
|
+
}
|
|
31
|
+
export function futureDateRequiredMsg() {
|
|
32
|
+
return "Date must be in the future";
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=validationErrorMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationErrorMessages.js","sourceRoot":"","sources":["../../src/utils/validationErrorMessages.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,GAAG,KAAK,cAAc,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,OAAO,qBAAqB,SAAS,EAAE,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,OAAO,qBAAqB,SAAS,EAAE,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAa,EAAE,MAAc;IAClE,OAAO,GAAG,KAAK,yBAAyB,MAAM,EAAE,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,sJAAsJ,CAAC;AAChK,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,oCAAoC,KAAK,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,GAAG,KAAK,qBAAqB,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,4BAA4B,CAAC;AACtC,CAAC"}
|
package/package.json
CHANGED