ayiin 2.0.7 → 2.0.9
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/ayiin/bin/cli.d.ts +2 -0
- package/ayiin/bin/cli.js +27 -0
- package/ayiin/methods/index.d.ts +10 -5
- package/ayiin/methods/index.js +5 -5
- package/ayiin/methods/response.d.ts +10 -5
- package/ayiin/methods/response.js +10 -5
- package/package.json +4 -1
package/ayiin/bin/cli.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
8
|
+
// CLI entry point
|
|
9
|
+
console.log("Welcome to ayiin CLI!");
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
if (args.length === 0) {
|
|
12
|
+
console.log("Usage: ayiin <command>");
|
|
13
|
+
process.exit(0);
|
|
14
|
+
}
|
|
15
|
+
switch (args[0]) {
|
|
16
|
+
case "hello":
|
|
17
|
+
console.log("Hai Ayiin, CLI sudah jalan!");
|
|
18
|
+
break;
|
|
19
|
+
case "version":
|
|
20
|
+
console.log(`ayiin CLI v${package_json_1.default.version}`);
|
|
21
|
+
break;
|
|
22
|
+
case "help":
|
|
23
|
+
console.log("Available commands: hello, version, help");
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
console.log(`Unknown command: ${args[0]}`);
|
|
27
|
+
}
|
package/ayiin/methods/index.d.ts
CHANGED
|
@@ -54,30 +54,35 @@ declare class BaseMethods<C extends Crypt, T extends Tools, R extends ResponseAp
|
|
|
54
54
|
responseMessage: string;
|
|
55
55
|
responseData: any;
|
|
56
56
|
};
|
|
57
|
-
badRequestResponse: (caption: string, title?: string) => {
|
|
57
|
+
badRequestResponse: (caption: string, title?: string, data?: any) => {
|
|
58
58
|
responseCode: number;
|
|
59
59
|
responseSuccess: boolean;
|
|
60
60
|
responseMessage: string;
|
|
61
|
+
responseData: any;
|
|
61
62
|
};
|
|
62
|
-
invalidFieldsResponse: (caption: string) => {
|
|
63
|
+
invalidFieldsResponse: (caption: string, data?: any) => {
|
|
63
64
|
responseCode: number;
|
|
64
65
|
responseSuccess: boolean;
|
|
65
66
|
responseMessage: string;
|
|
67
|
+
responseData: any;
|
|
66
68
|
};
|
|
67
|
-
notFoundResponse: (caption: string) => {
|
|
69
|
+
notFoundResponse: (caption: string, data?: any) => {
|
|
68
70
|
responseCode: number;
|
|
69
71
|
responseSuccess: boolean;
|
|
70
72
|
responseMessage: string;
|
|
73
|
+
responseData: any;
|
|
71
74
|
};
|
|
72
|
-
unauthorizedResponse: (caption: string) => {
|
|
75
|
+
unauthorizedResponse: (caption: string, data?: any) => {
|
|
73
76
|
responseCode: number;
|
|
74
77
|
responseSuccess: boolean;
|
|
75
78
|
responseMessage: string;
|
|
79
|
+
responseData: any;
|
|
76
80
|
};
|
|
77
|
-
internalServerErrorResponse: (caption: string) => {
|
|
81
|
+
internalServerErrorResponse: (caption: string, data?: any) => {
|
|
78
82
|
responseCode: number;
|
|
79
83
|
responseSuccess: boolean;
|
|
80
84
|
responseMessage: string;
|
|
85
|
+
responseData: any;
|
|
81
86
|
};
|
|
82
87
|
}
|
|
83
88
|
declare class Methods extends BaseMethods<Crypt, Tools, ResponseApi> {
|
package/ayiin/methods/index.js
CHANGED
|
@@ -58,11 +58,11 @@ class BaseMethods {
|
|
|
58
58
|
* */
|
|
59
59
|
randomString = (length, prefix) => this.tools.randomString(length, prefix);
|
|
60
60
|
successResponse = (caption, data, code) => this.response.successResponse(caption, data, code);
|
|
61
|
-
badRequestResponse = (caption, title) => this.response.badRequestResponse(caption, title);
|
|
62
|
-
invalidFieldsResponse = (caption) => this.response.invalidFieldsResponse(caption);
|
|
63
|
-
notFoundResponse = (caption) => this.response.notFoundResponse(caption);
|
|
64
|
-
unauthorizedResponse = (caption) => this.response.unauthorizedResponse(caption);
|
|
65
|
-
internalServerErrorResponse = (caption) => this.response.internalServerErrorResponse(caption);
|
|
61
|
+
badRequestResponse = (caption, title, data) => this.response.badRequestResponse(caption, title, data);
|
|
62
|
+
invalidFieldsResponse = (caption, data) => this.response.invalidFieldsResponse(caption, data);
|
|
63
|
+
notFoundResponse = (caption, data) => this.response.notFoundResponse(caption, data);
|
|
64
|
+
unauthorizedResponse = (caption, data) => this.response.unauthorizedResponse(caption, data);
|
|
65
|
+
internalServerErrorResponse = (caption, data) => this.response.internalServerErrorResponse(caption, data);
|
|
66
66
|
}
|
|
67
67
|
class Methods extends BaseMethods {
|
|
68
68
|
}
|
|
@@ -5,30 +5,35 @@ declare class ResponseApi {
|
|
|
5
5
|
responseMessage: string;
|
|
6
6
|
responseData: any;
|
|
7
7
|
};
|
|
8
|
-
badRequestResponse: (caption: string, title?: string) => {
|
|
8
|
+
badRequestResponse: (caption: string, title?: string, data?: any) => {
|
|
9
9
|
responseCode: number;
|
|
10
10
|
responseSuccess: boolean;
|
|
11
11
|
responseMessage: string;
|
|
12
|
+
responseData: any;
|
|
12
13
|
};
|
|
13
|
-
invalidFieldsResponse: (caption: string) => {
|
|
14
|
+
invalidFieldsResponse: (caption: string, data?: any) => {
|
|
14
15
|
responseCode: number;
|
|
15
16
|
responseSuccess: boolean;
|
|
16
17
|
responseMessage: string;
|
|
18
|
+
responseData: any;
|
|
17
19
|
};
|
|
18
|
-
notFoundResponse: (caption: string) => {
|
|
20
|
+
notFoundResponse: (caption: string, data?: any) => {
|
|
19
21
|
responseCode: number;
|
|
20
22
|
responseSuccess: boolean;
|
|
21
23
|
responseMessage: string;
|
|
24
|
+
responseData: any;
|
|
22
25
|
};
|
|
23
|
-
unauthorizedResponse: (caption: string) => {
|
|
26
|
+
unauthorizedResponse: (caption: string, data?: any) => {
|
|
24
27
|
responseCode: number;
|
|
25
28
|
responseSuccess: boolean;
|
|
26
29
|
responseMessage: string;
|
|
30
|
+
responseData: any;
|
|
27
31
|
};
|
|
28
|
-
internalServerErrorResponse: (caption: string) => {
|
|
32
|
+
internalServerErrorResponse: (caption: string, data?: any) => {
|
|
29
33
|
responseCode: number;
|
|
30
34
|
responseSuccess: boolean;
|
|
31
35
|
responseMessage: string;
|
|
36
|
+
responseData: any;
|
|
32
37
|
};
|
|
33
38
|
}
|
|
34
39
|
export default ResponseApi;
|
|
@@ -10,39 +10,44 @@ class ResponseApi {
|
|
|
10
10
|
responseData: data,
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
badRequestResponse = (caption, title) => {
|
|
13
|
+
badRequestResponse = (caption, title, data) => {
|
|
14
14
|
return {
|
|
15
15
|
responseCode: 4007400,
|
|
16
16
|
responseSuccess: false,
|
|
17
17
|
responseMessage: `[${title ? title : "Bad Request"}] - ${caption}`,
|
|
18
|
+
responseData: data,
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
|
-
invalidFieldsResponse = (caption) => {
|
|
21
|
+
invalidFieldsResponse = (caption, data) => {
|
|
21
22
|
return {
|
|
22
23
|
responseCode: 4007401,
|
|
23
24
|
responseSuccess: false,
|
|
24
25
|
responseMessage: `[Invalid Fields] - ${caption}`,
|
|
26
|
+
responseData: data,
|
|
25
27
|
};
|
|
26
28
|
};
|
|
27
|
-
notFoundResponse = (caption) => {
|
|
29
|
+
notFoundResponse = (caption, data) => {
|
|
28
30
|
return {
|
|
29
31
|
responseCode: 4047400,
|
|
30
32
|
responseSuccess: false,
|
|
31
33
|
responseMessage: `[Not Found] - ${caption}`,
|
|
34
|
+
responseData: data,
|
|
32
35
|
};
|
|
33
36
|
};
|
|
34
|
-
unauthorizedResponse = (caption) => {
|
|
37
|
+
unauthorizedResponse = (caption, data) => {
|
|
35
38
|
return {
|
|
36
39
|
responseCode: 4017400,
|
|
37
40
|
responseSuccess: false,
|
|
38
41
|
responseMessage: `[Unauthorized] - ${caption}`,
|
|
42
|
+
responseData: data,
|
|
39
43
|
};
|
|
40
44
|
};
|
|
41
|
-
internalServerErrorResponse = (caption) => {
|
|
45
|
+
internalServerErrorResponse = (caption, data) => {
|
|
42
46
|
return {
|
|
43
47
|
responseCode: 5007400,
|
|
44
48
|
responseSuccess: false,
|
|
45
49
|
responseMessage: `[Internal Server Error] - ${caption}`,
|
|
50
|
+
responseData: data,
|
|
46
51
|
};
|
|
47
52
|
};
|
|
48
53
|
}
|
package/package.json
CHANGED