@remnawave/backend-contract 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/api/controllers/api-tokens.ts +7 -0
  2. package/api/controllers/auth.ts +5 -0
  3. package/api/controllers/hosts.ts +9 -0
  4. package/api/controllers/inbounds.ts +5 -0
  5. package/api/controllers/index.ts +9 -0
  6. package/api/controllers/keygen.ts +5 -0
  7. package/api/controllers/nodes.ts +14 -0
  8. package/api/controllers/subscription.ts +6 -0
  9. package/api/controllers/users.ts +13 -0
  10. package/api/controllers/xray.ts +6 -0
  11. package/api/index.ts +2 -0
  12. package/api/routes.ts +73 -0
  13. package/build/api/controllers/api-tokens.js +9 -0
  14. package/build/api/controllers/auth.js +7 -0
  15. package/build/api/controllers/hosts.js +11 -0
  16. package/build/api/controllers/inbounds.js +7 -0
  17. package/build/api/controllers/index.js +25 -0
  18. package/build/api/controllers/keygen.js +7 -0
  19. package/build/api/controllers/nodes.js +15 -0
  20. package/build/api/controllers/subscription.js +8 -0
  21. package/build/api/controllers/users.js +15 -0
  22. package/build/api/controllers/xray.js +8 -0
  23. package/build/api/index.js +18 -0
  24. package/build/api/routes.js +81 -0
  25. package/build/commands/api-tokens/create.command.js +19 -0
  26. package/build/commands/api-tokens/delete.command.js +15 -0
  27. package/build/commands/api-tokens/find.command.js +13 -0
  28. package/build/commands/api-tokens/index.js +19 -0
  29. package/build/commands/auth/index.js +17 -0
  30. package/build/commands/auth/login.command.js +18 -0
  31. package/build/commands/hosts/create.command.js +50 -0
  32. package/build/commands/hosts/delete.command.js +17 -0
  33. package/build/commands/hosts/index.js +18 -0
  34. package/build/commands/inbounds/get-inbounds.command.js +13 -0
  35. package/build/commands/inbounds/index.js +17 -0
  36. package/build/commands/index.js +25 -0
  37. package/build/commands/keygen/get-pubkey.command.js +14 -0
  38. package/build/commands/keygen/index.js +17 -0
  39. package/build/commands/nodes/create.command.js +36 -0
  40. package/build/commands/nodes/delete.command.js +17 -0
  41. package/build/commands/nodes/disable.command.js +16 -0
  42. package/build/commands/nodes/enable.command.js +16 -0
  43. package/build/commands/nodes/get-all.command.js +13 -0
  44. package/build/commands/nodes/get-one.command.js +16 -0
  45. package/build/commands/nodes/index.js +25 -0
  46. package/build/commands/nodes/restart-all.command.js +14 -0
  47. package/build/commands/nodes/restart.command.js +17 -0
  48. package/build/commands/nodes/update.command.js +38 -0
  49. package/build/commands/subscription/get-subscription-by-short-uuid.command.js +12 -0
  50. package/build/commands/subscription/get-subscription-info-by-short-uuid.command.js +28 -0
  51. package/build/commands/subscription/index.js +18 -0
  52. package/build/commands/users/create-user.command.js +94 -0
  53. package/build/commands/users/delete-user.command.js +17 -0
  54. package/build/commands/users/disable-user.command.ts.js +16 -0
  55. package/build/commands/users/enable-user.command.js +16 -0
  56. package/build/commands/users/get-all-users.command.js +23 -0
  57. package/build/commands/users/get-user-by-short-uuid.command.js +16 -0
  58. package/build/commands/users/get-user-by-subscription-uuid.command.js +16 -0
  59. package/build/commands/users/get-user-by-uuid.command.js +16 -0
  60. package/build/commands/users/index.js +25 -0
  61. package/build/commands/users/revoke-user-subscription.command.js +16 -0
  62. package/build/commands/xray/get-config.command.js +14 -0
  63. package/build/commands/xray/index.js +17 -0
  64. package/build/constants/errors/errors.js +236 -0
  65. package/build/constants/errors/index.js +17 -0
  66. package/build/constants/hosts/alpn.js +9 -0
  67. package/build/constants/hosts/fingerprints.js +15 -0
  68. package/build/constants/hosts/index.js +18 -0
  69. package/build/constants/index.js +22 -0
  70. package/build/constants/nodes/cycle/cycle.js +8 -0
  71. package/build/constants/nodes/cycle/index.js +17 -0
  72. package/build/constants/nodes/index.js +18 -0
  73. package/build/constants/nodes/status/index.js +17 -0
  74. package/build/constants/nodes/status/status.constant.js +9 -0
  75. package/build/constants/roles/index.js +17 -0
  76. package/build/constants/roles/role.js +7 -0
  77. package/build/constants/templates/index.js +18 -0
  78. package/build/constants/templates/template-keys.js +4 -0
  79. package/build/constants/templates/user-statuses.js +9 -0
  80. package/build/constants/users/index.js +18 -0
  81. package/build/constants/users/reset-periods/index.js +17 -0
  82. package/build/constants/users/reset-periods/reset-periods.constant.js +11 -0
  83. package/build/constants/users/status/index.js +17 -0
  84. package/build/constants/users/status/status.constant.js +10 -0
  85. package/build/index.js +20 -0
  86. package/build/models/api-tokens.schema.js +12 -0
  87. package/build/models/auth.schema.js +7 -0
  88. package/build/models/hosts.schema.js +19 -0
  89. package/build/models/inbounds.schema.js +9 -0
  90. package/build/models/index.js +22 -0
  91. package/build/models/nodes.schema.js +28 -0
  92. package/build/models/users.schema.js +34 -0
  93. package/commands/api-tokens/create.command.ts +22 -0
  94. package/commands/api-tokens/delete.command.ts +18 -0
  95. package/commands/api-tokens/find.command.ts +13 -0
  96. package/commands/api-tokens/index.ts +3 -0
  97. package/commands/auth/index.ts +1 -0
  98. package/commands/auth/login.command.ts +20 -0
  99. package/commands/hosts/create.command.ts +52 -0
  100. package/commands/hosts/delete.command.ts +20 -0
  101. package/commands/hosts/index.ts +2 -0
  102. package/commands/inbounds/get-inbounds.command.ts +13 -0
  103. package/commands/inbounds/index.ts +1 -0
  104. package/commands/index.ts +9 -0
  105. package/commands/keygen/get-pubkey.command.ts +14 -0
  106. package/commands/keygen/index.ts +1 -0
  107. package/commands/nodes/create.command.ts +39 -0
  108. package/commands/nodes/delete.command.ts +20 -0
  109. package/commands/nodes/disable.command.ts +19 -0
  110. package/commands/nodes/enable.command.ts +19 -0
  111. package/commands/nodes/get-all.command.ts +13 -0
  112. package/commands/nodes/get-one.command.ts +19 -0
  113. package/commands/nodes/index.ts +9 -0
  114. package/commands/nodes/restart-all.command.ts +13 -0
  115. package/commands/nodes/restart.command.ts +20 -0
  116. package/commands/nodes/update.command.ts +41 -0
  117. package/commands/subscription/get-subscription-by-short-uuid.command.ts +12 -0
  118. package/commands/subscription/get-subscription-info-by-short-uuid.command.ts +31 -0
  119. package/commands/subscription/index.ts +2 -0
  120. package/commands/users/create-user.command.ts +103 -0
  121. package/commands/users/delete-user.command.ts +19 -0
  122. package/commands/users/disable-user.command.ts.ts +18 -0
  123. package/commands/users/enable-user.command.ts +19 -0
  124. package/commands/users/get-all-users.command.ts +26 -0
  125. package/commands/users/get-user-by-short-uuid.command.ts +19 -0
  126. package/commands/users/get-user-by-subscription-uuid.command.ts +19 -0
  127. package/commands/users/get-user-by-uuid.command.ts +19 -0
  128. package/commands/users/index.ts +9 -0
  129. package/commands/users/revoke-user-subscription.command.ts +19 -0
  130. package/commands/xray/get-config.command.ts +12 -0
  131. package/commands/xray/index.ts +1 -0
  132. package/constants/errors/errors.ts +233 -0
  133. package/constants/errors/index.ts +1 -0
  134. package/constants/hosts/alpn.ts +8 -0
  135. package/constants/hosts/fingerprints.ts +14 -0
  136. package/constants/hosts/index.ts +2 -0
  137. package/constants/index.ts +6 -0
  138. package/constants/nodes/cycle/cycle.ts +7 -0
  139. package/constants/nodes/cycle/index.ts +1 -0
  140. package/constants/nodes/index.ts +2 -0
  141. package/constants/nodes/status/index.ts +1 -0
  142. package/constants/nodes/status/status.constant.ts +8 -0
  143. package/constants/roles/index.ts +1 -0
  144. package/constants/roles/role.ts +7 -0
  145. package/constants/templates/index.ts +2 -0
  146. package/constants/templates/template-keys.ts +2 -0
  147. package/constants/templates/user-statuses.ts +6 -0
  148. package/constants/users/index.ts +2 -0
  149. package/constants/users/reset-periods/index.ts +1 -0
  150. package/constants/users/reset-periods/reset-periods.constant.ts +10 -0
  151. package/constants/users/status/index.ts +1 -0
  152. package/constants/users/status/status.constant.ts +9 -0
  153. package/index.ts +4 -0
  154. package/models/api-tokens.schema.ts +11 -0
  155. package/models/auth.schema.ts +5 -0
  156. package/models/hosts.schema.ts +17 -0
  157. package/models/inbounds.schema.ts +7 -0
  158. package/models/index.ts +6 -0
  159. package/models/nodes.schema.ts +28 -0
  160. package/models/users.schema.ts +38 -0
  161. package/package.json +16 -0
  162. package/tsconfig.json +103 -0
@@ -0,0 +1,7 @@
1
+ export const API_TOKENS_CONTROLLER = 'tokens' as const;
2
+
3
+ export const API_TOKENS_ROUTES = {
4
+ CREATE: '',
5
+ DELETE: '',
6
+ GET_ALL: '',
7
+ } as const;
@@ -0,0 +1,5 @@
1
+ export const AUTH_CONTROLLER = 'auth' as const;
2
+
3
+ export const AUTH_ROUTES = {
4
+ LOGIN: 'login',
5
+ } as const;
@@ -0,0 +1,9 @@
1
+ export const HOSTS_CONTROLLER = 'hosts' as const;
2
+
3
+ export const HOSTS_ROUTES = {
4
+ CREATE: '',
5
+ DELETE: ':uuid',
6
+ GET_ALL: '',
7
+ UPDATE: '',
8
+ UPDATE_MANY: 'many',
9
+ } as const;
@@ -0,0 +1,5 @@
1
+ export const INBOUNDS_CONTROLLER = 'inbounds' as const;
2
+
3
+ export const INBOUNDS_ROUTES = {
4
+ GET_INBOUNDS: '',
5
+ } as const;
@@ -0,0 +1,9 @@
1
+ export * from './api-tokens';
2
+ export * from './auth';
3
+ export * from './hosts';
4
+ export * from './inbounds';
5
+ export * from './keygen';
6
+ export * from './nodes';
7
+ export * from './subscription';
8
+ export * from './users';
9
+ export * from './xray';
@@ -0,0 +1,5 @@
1
+ export const KEYGEN_CONTROLLER = 'keygen' as const;
2
+
3
+ export const KEYGEN_ROUTES = {
4
+ GET: 'get',
5
+ } as const;
@@ -0,0 +1,14 @@
1
+ export const NODES_CONTROLLER = 'nodes' as const;
2
+
3
+ export const NODES_ROUTES = {
4
+ CREATE: 'create',
5
+ ENABLE: 'enable',
6
+ RESTART: 'restart',
7
+ RESTART_ALL: 'restart-all',
8
+
9
+ DELETE: 'delete',
10
+ UPDATE: 'update',
11
+ DISABLE: 'disable',
12
+ GET_ALL: 'get-all',
13
+ GET_ONE: 'get-one',
14
+ } as const;
@@ -0,0 +1,6 @@
1
+ export const SUBSCRIPTION_CONTROLLER = 'sub' as const;
2
+
3
+ export const SUBSCRIPTION_ROUTES = {
4
+ GET: '',
5
+ GET_INFO: '/info',
6
+ } as const;
@@ -0,0 +1,13 @@
1
+ export const USERS_CONTROLLER = 'users' as const;
2
+
3
+ export const USERS_ROUTES = {
4
+ CREATE: '',
5
+ GET_BY_UUID: '/:uuid',
6
+ GET_BY_SHORT_UUID: 'short-uuid/:shortUuid',
7
+ GET_BY_SUBSCRIPTION_UUID: 'sub-uuid/:subscriptionUuid',
8
+ GET_ALL: '',
9
+ REVOKE_SUBSCRIPTION: '/revoke/:uuid',
10
+ DISABLE_USER: '/disable/:uuid',
11
+ ENABLE_USER: '/enable/:uuid',
12
+ DELETE_USER: '/delete/:uuid',
13
+ } as const;
@@ -0,0 +1,6 @@
1
+ export const XRAY_CONTROLLER = 'xray' as const;
2
+
3
+ export const XRAY_ROUTES = {
4
+ GET_CONFIG: 'get-config',
5
+ UPDATE_CONFIG: 'update-config',
6
+ } as const;
package/api/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './routes';
2
+ export * from './controllers';
package/api/routes.ts ADDED
@@ -0,0 +1,73 @@
1
+ import * as CONTROLLERS from './controllers';
2
+
3
+ export const ROOT = '/api' as const;
4
+
5
+ export const REST_API = {
6
+ AUTH: {
7
+ LOGIN: `${ROOT}/${CONTROLLERS.AUTH_CONTROLLER}/${CONTROLLERS.AUTH_ROUTES.LOGIN}`,
8
+ },
9
+ API_TOKENS: {
10
+ CREATE: `${ROOT}/${CONTROLLERS.API_TOKENS_CONTROLLER}/${CONTROLLERS.API_TOKENS_ROUTES.CREATE}`,
11
+ DELETE: (uuid: string) =>
12
+ `${ROOT}/${CONTROLLERS.API_TOKENS_CONTROLLER}/${CONTROLLERS.API_TOKENS_ROUTES.DELETE}/${uuid}`,
13
+ GET_ALL: `${ROOT}/${CONTROLLERS.API_TOKENS_CONTROLLER}/${CONTROLLERS.API_TOKENS_ROUTES.GET_ALL}`,
14
+ },
15
+ KEYGEN: {
16
+ GET: `${ROOT}/${CONTROLLERS.KEYGEN_CONTROLLER}/${CONTROLLERS.KEYGEN_ROUTES.GET}`,
17
+ },
18
+ NODES: {
19
+ CREATE: `${ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.CREATE}`,
20
+ DELETE: (uuid: string) =>
21
+ `${ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.DELETE}/${uuid}`,
22
+ UPDATE: `${ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.UPDATE}`,
23
+ GET_ALL: `${ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.GET_ALL}`,
24
+ RESTART: (uuid: string) =>
25
+ `${ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.RESTART}/${uuid}`,
26
+ GET_ONE: (uuid: string) =>
27
+ `${ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.GET_ONE}/${uuid}`,
28
+ DISABLE: (uuid: string) =>
29
+ `${ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.DISABLE}/${uuid}`,
30
+ ENABLE: (uuid: string) =>
31
+ `${ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.ENABLE}/${uuid}`,
32
+ RESTART_ALL: `${ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.RESTART_ALL}`,
33
+ },
34
+ XRAY: {
35
+ GET_CONFIG: `${ROOT}/${CONTROLLERS.XRAY_CONTROLLER}/${CONTROLLERS.XRAY_ROUTES.GET_CONFIG}`,
36
+ UPDATE_CONFIG: `${ROOT}/${CONTROLLERS.XRAY_CONTROLLER}/${CONTROLLERS.XRAY_ROUTES.UPDATE_CONFIG}`,
37
+ },
38
+ INBOUNDS: {
39
+ GET_INBOUNDS: `${ROOT}/${CONTROLLERS.INBOUNDS_CONTROLLER}/${CONTROLLERS.INBOUNDS_ROUTES.GET_INBOUNDS}`,
40
+ },
41
+ USERS: {
42
+ CREATE: `${ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.CREATE}`,
43
+ GET_BY_UUID: (uuid: string) =>
44
+ `${ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.GET_BY_UUID}/${uuid}`,
45
+ GET_BY_SHORT_UUID: (shortUuid: string) =>
46
+ `${ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.GET_BY_SHORT_UUID}/${shortUuid}`,
47
+ GET_BY_SUBSCRIPTION_UUID: (subscriptionUuid: string) =>
48
+ `${ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.GET_BY_SUBSCRIPTION_UUID}/${subscriptionUuid}`,
49
+ GET_ALL: `${ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.GET_ALL}`,
50
+ REVOKE_SUBSCRIPTION: (uuid: string) =>
51
+ `${ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.REVOKE_SUBSCRIPTION}/${uuid}`,
52
+ DISABLE_USER: (uuid: string) =>
53
+ `${ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.DISABLE_USER}/${uuid}`,
54
+ ENABLE_USER: (uuid: string) =>
55
+ `${ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.ENABLE_USER}/${uuid}`,
56
+ DELETE_USER: (uuid: string) =>
57
+ `${ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.DELETE_USER}/${uuid}`,
58
+ },
59
+ SUBSCRIPTION: {
60
+ GET: (shortUuid: string) =>
61
+ `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET}/${shortUuid}`,
62
+ GET_INFO: (shortUuid: string) =>
63
+ `${ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${shortUuid}${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_INFO}`,
64
+ },
65
+ HOSTS: {
66
+ CREATE: `${ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.CREATE}`,
67
+ GET_ALL: `${ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.GET_ALL}`,
68
+ UPDATE: `${ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.UPDATE}`,
69
+ UPDATE_MANY: `${ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.UPDATE_MANY}`,
70
+ DELETE: (uuid: string) =>
71
+ `${ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.DELETE}/${uuid}`,
72
+ },
73
+ } as const;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.API_TOKENS_ROUTES = exports.API_TOKENS_CONTROLLER = void 0;
4
+ exports.API_TOKENS_CONTROLLER = 'tokens';
5
+ exports.API_TOKENS_ROUTES = {
6
+ CREATE: '',
7
+ DELETE: '',
8
+ GET_ALL: '',
9
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AUTH_ROUTES = exports.AUTH_CONTROLLER = void 0;
4
+ exports.AUTH_CONTROLLER = 'auth';
5
+ exports.AUTH_ROUTES = {
6
+ LOGIN: 'login',
7
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HOSTS_ROUTES = exports.HOSTS_CONTROLLER = void 0;
4
+ exports.HOSTS_CONTROLLER = 'hosts';
5
+ exports.HOSTS_ROUTES = {
6
+ CREATE: '',
7
+ DELETE: ':uuid',
8
+ GET_ALL: '',
9
+ UPDATE: '',
10
+ UPDATE_MANY: 'many',
11
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INBOUNDS_ROUTES = exports.INBOUNDS_CONTROLLER = void 0;
4
+ exports.INBOUNDS_CONTROLLER = 'inbounds';
5
+ exports.INBOUNDS_ROUTES = {
6
+ GET_INBOUNDS: '',
7
+ };
@@ -0,0 +1,25 @@
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("./api-tokens"), exports);
18
+ __exportStar(require("./auth"), exports);
19
+ __exportStar(require("./hosts"), exports);
20
+ __exportStar(require("./inbounds"), exports);
21
+ __exportStar(require("./keygen"), exports);
22
+ __exportStar(require("./nodes"), exports);
23
+ __exportStar(require("./subscription"), exports);
24
+ __exportStar(require("./users"), exports);
25
+ __exportStar(require("./xray"), exports);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEYGEN_ROUTES = exports.KEYGEN_CONTROLLER = void 0;
4
+ exports.KEYGEN_CONTROLLER = 'keygen';
5
+ exports.KEYGEN_ROUTES = {
6
+ GET: 'get',
7
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NODES_ROUTES = exports.NODES_CONTROLLER = void 0;
4
+ exports.NODES_CONTROLLER = 'nodes';
5
+ exports.NODES_ROUTES = {
6
+ CREATE: 'create',
7
+ ENABLE: 'enable',
8
+ RESTART: 'restart',
9
+ RESTART_ALL: 'restart-all',
10
+ DELETE: 'delete',
11
+ UPDATE: 'update',
12
+ DISABLE: 'disable',
13
+ GET_ALL: 'get-all',
14
+ GET_ONE: 'get-one',
15
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUBSCRIPTION_ROUTES = exports.SUBSCRIPTION_CONTROLLER = void 0;
4
+ exports.SUBSCRIPTION_CONTROLLER = 'sub';
5
+ exports.SUBSCRIPTION_ROUTES = {
6
+ GET: '',
7
+ GET_INFO: '/info',
8
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USERS_ROUTES = exports.USERS_CONTROLLER = void 0;
4
+ exports.USERS_CONTROLLER = 'users';
5
+ exports.USERS_ROUTES = {
6
+ CREATE: '',
7
+ GET_BY_UUID: '/:uuid',
8
+ GET_BY_SHORT_UUID: 'short-uuid/:shortUuid',
9
+ GET_BY_SUBSCRIPTION_UUID: 'sub-uuid/:subscriptionUuid',
10
+ GET_ALL: '',
11
+ REVOKE_SUBSCRIPTION: '/revoke/:uuid',
12
+ DISABLE_USER: '/disable/:uuid',
13
+ ENABLE_USER: '/enable/:uuid',
14
+ DELETE_USER: '/delete/:uuid',
15
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XRAY_ROUTES = exports.XRAY_CONTROLLER = void 0;
4
+ exports.XRAY_CONTROLLER = 'xray';
5
+ exports.XRAY_ROUTES = {
6
+ GET_CONFIG: 'get-config',
7
+ UPDATE_CONFIG: 'update-config',
8
+ };
@@ -0,0 +1,18 @@
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("./routes"), exports);
18
+ __exportStar(require("./controllers"), exports);
@@ -0,0 +1,81 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.REST_API = exports.ROOT = void 0;
27
+ const CONTROLLERS = __importStar(require("./controllers"));
28
+ exports.ROOT = '/api';
29
+ exports.REST_API = {
30
+ AUTH: {
31
+ LOGIN: `${exports.ROOT}/${CONTROLLERS.AUTH_CONTROLLER}/${CONTROLLERS.AUTH_ROUTES.LOGIN}`,
32
+ },
33
+ API_TOKENS: {
34
+ CREATE: `${exports.ROOT}/${CONTROLLERS.API_TOKENS_CONTROLLER}/${CONTROLLERS.API_TOKENS_ROUTES.CREATE}`,
35
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.API_TOKENS_CONTROLLER}/${CONTROLLERS.API_TOKENS_ROUTES.DELETE}/${uuid}`,
36
+ GET_ALL: `${exports.ROOT}/${CONTROLLERS.API_TOKENS_CONTROLLER}/${CONTROLLERS.API_TOKENS_ROUTES.GET_ALL}`,
37
+ },
38
+ KEYGEN: {
39
+ GET: `${exports.ROOT}/${CONTROLLERS.KEYGEN_CONTROLLER}/${CONTROLLERS.KEYGEN_ROUTES.GET}`,
40
+ },
41
+ NODES: {
42
+ CREATE: `${exports.ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.CREATE}`,
43
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.DELETE}/${uuid}`,
44
+ UPDATE: `${exports.ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.UPDATE}`,
45
+ GET_ALL: `${exports.ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.GET_ALL}`,
46
+ RESTART: (uuid) => `${exports.ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.RESTART}/${uuid}`,
47
+ GET_ONE: (uuid) => `${exports.ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.GET_ONE}/${uuid}`,
48
+ DISABLE: (uuid) => `${exports.ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.DISABLE}/${uuid}`,
49
+ ENABLE: (uuid) => `${exports.ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.ENABLE}/${uuid}`,
50
+ RESTART_ALL: `${exports.ROOT}/${CONTROLLERS.NODES_CONTROLLER}/${CONTROLLERS.NODES_ROUTES.RESTART_ALL}`,
51
+ },
52
+ XRAY: {
53
+ GET_CONFIG: `${exports.ROOT}/${CONTROLLERS.XRAY_CONTROLLER}/${CONTROLLERS.XRAY_ROUTES.GET_CONFIG}`,
54
+ UPDATE_CONFIG: `${exports.ROOT}/${CONTROLLERS.XRAY_CONTROLLER}/${CONTROLLERS.XRAY_ROUTES.UPDATE_CONFIG}`,
55
+ },
56
+ INBOUNDS: {
57
+ GET_INBOUNDS: `${exports.ROOT}/${CONTROLLERS.INBOUNDS_CONTROLLER}/${CONTROLLERS.INBOUNDS_ROUTES.GET_INBOUNDS}`,
58
+ },
59
+ USERS: {
60
+ CREATE: `${exports.ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.CREATE}`,
61
+ GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.GET_BY_UUID}/${uuid}`,
62
+ GET_BY_SHORT_UUID: (shortUuid) => `${exports.ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.GET_BY_SHORT_UUID}/${shortUuid}`,
63
+ GET_BY_SUBSCRIPTION_UUID: (subscriptionUuid) => `${exports.ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.GET_BY_SUBSCRIPTION_UUID}/${subscriptionUuid}`,
64
+ GET_ALL: `${exports.ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.GET_ALL}`,
65
+ REVOKE_SUBSCRIPTION: (uuid) => `${exports.ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.REVOKE_SUBSCRIPTION}/${uuid}`,
66
+ DISABLE_USER: (uuid) => `${exports.ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.DISABLE_USER}/${uuid}`,
67
+ ENABLE_USER: (uuid) => `${exports.ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.ENABLE_USER}/${uuid}`,
68
+ DELETE_USER: (uuid) => `${exports.ROOT}/${CONTROLLERS.USERS_CONTROLLER}/${CONTROLLERS.USERS_ROUTES.DELETE_USER}/${uuid}`,
69
+ },
70
+ SUBSCRIPTION: {
71
+ GET: (shortUuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET}/${shortUuid}`,
72
+ GET_INFO: (shortUuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_CONTROLLER}/${shortUuid}${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_INFO}`,
73
+ },
74
+ HOSTS: {
75
+ CREATE: `${exports.ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.CREATE}`,
76
+ GET_ALL: `${exports.ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.GET_ALL}`,
77
+ UPDATE: `${exports.ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.UPDATE}`,
78
+ UPDATE_MANY: `${exports.ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.UPDATE_MANY}`,
79
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.HOSTS_CONTROLLER}/${CONTROLLERS.HOSTS_ROUTES.DELETE}/${uuid}`,
80
+ },
81
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateApiTokenCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var CreateApiTokenCommand;
7
+ (function (CreateApiTokenCommand) {
8
+ CreateApiTokenCommand.url = api_1.REST_API.API_TOKENS.CREATE;
9
+ CreateApiTokenCommand.RequestSchema = zod_1.z.object({
10
+ tokenName: zod_1.z.string(),
11
+ tokenDescription: zod_1.z.string().nullable(),
12
+ });
13
+ CreateApiTokenCommand.ResponseSchema = zod_1.z.object({
14
+ response: zod_1.z.object({
15
+ token: zod_1.z.string(),
16
+ uuid: zod_1.z.string(),
17
+ }),
18
+ });
19
+ })(CreateApiTokenCommand || (exports.CreateApiTokenCommand = CreateApiTokenCommand = {}));
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteApiTokenCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var DeleteApiTokenCommand;
7
+ (function (DeleteApiTokenCommand) {
8
+ DeleteApiTokenCommand.url = api_1.REST_API.API_TOKENS.DELETE;
9
+ DeleteApiTokenCommand.RequestSchema = zod_1.z.object({
10
+ uuid: zod_1.z.string().uuid(),
11
+ });
12
+ DeleteApiTokenCommand.ResponseSchema = zod_1.z.object({
13
+ response: zod_1.z.boolean(),
14
+ });
15
+ })(DeleteApiTokenCommand || (exports.DeleteApiTokenCommand = DeleteApiTokenCommand = {}));
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindAllApiTokensCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const api_tokens_schema_1 = require("../../models/api-tokens.schema");
7
+ var FindAllApiTokensCommand;
8
+ (function (FindAllApiTokensCommand) {
9
+ FindAllApiTokensCommand.url = api_1.REST_API.API_TOKENS.GET_ALL;
10
+ FindAllApiTokensCommand.ResponseSchema = zod_1.z.object({
11
+ response: zod_1.z.array(api_tokens_schema_1.ApiTokensSchema),
12
+ });
13
+ })(FindAllApiTokensCommand || (exports.FindAllApiTokensCommand = FindAllApiTokensCommand = {}));
@@ -0,0 +1,19 @@
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("./create.command"), exports);
18
+ __exportStar(require("./delete.command"), exports);
19
+ __exportStar(require("./find.command"), exports);
@@ -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("./login.command"), exports);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoginCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var LoginCommand;
7
+ (function (LoginCommand) {
8
+ LoginCommand.url = api_1.REST_API.AUTH.LOGIN;
9
+ LoginCommand.RequestSchema = zod_1.z.object({
10
+ username: zod_1.z.string(),
11
+ password: zod_1.z.string(),
12
+ });
13
+ LoginCommand.ResponseSchema = zod_1.z.object({
14
+ response: zod_1.z.object({
15
+ accessToken: zod_1.z.string(),
16
+ }),
17
+ });
18
+ })(LoginCommand || (exports.LoginCommand = LoginCommand = {}));
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateHostCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const alpn_1 = require("../../constants/hosts/alpn");
7
+ const fingerprints_1 = require("../../constants/hosts/fingerprints");
8
+ const models_1 = require("../../models");
9
+ var CreateHostCommand;
10
+ (function (CreateHostCommand) {
11
+ CreateHostCommand.url = api_1.REST_API.HOSTS.CREATE;
12
+ CreateHostCommand.RequestSchema = models_1.HostsSchema.pick({}).extend({
13
+ inboundUuid: zod_1.z
14
+ .string({
15
+ invalid_type_error: 'Inbound UUID must be a string',
16
+ })
17
+ .uuid('Inbound UUID must be a valid UUID'),
18
+ viewPosition: zod_1.z
19
+ .number({
20
+ invalid_type_error: 'View position must be an integer',
21
+ })
22
+ .int()
23
+ .optional(),
24
+ remark: zod_1.z
25
+ .string({
26
+ invalid_type_error: 'Remark must be a string',
27
+ })
28
+ .max(40, {
29
+ message: 'Remark must be less than 40 characters',
30
+ }),
31
+ address: zod_1.z.string({
32
+ invalid_type_error: 'Address must be a string',
33
+ }),
34
+ port: zod_1.z
35
+ .number({
36
+ invalid_type_error: 'Port must be an integer',
37
+ })
38
+ .int(),
39
+ path: zod_1.z.string().optional(),
40
+ sni: zod_1.z.string().optional(),
41
+ host: zod_1.z.string().optional(),
42
+ alpn: zod_1.z.nativeEnum(alpn_1.ALPN).optional(),
43
+ fingerprint: zod_1.z.nativeEnum(fingerprints_1.FINGERPRINTS).optional(),
44
+ allowInsecure: zod_1.z.boolean().optional().default(false),
45
+ isDisabled: zod_1.z.boolean().optional().default(false),
46
+ });
47
+ CreateHostCommand.ResponseSchema = zod_1.z.object({
48
+ response: models_1.HostsSchema,
49
+ });
50
+ })(CreateHostCommand || (exports.CreateHostCommand = CreateHostCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteHostCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var DeleteHostCommand;
7
+ (function (DeleteHostCommand) {
8
+ DeleteHostCommand.url = api_1.REST_API.HOSTS.DELETE;
9
+ DeleteHostCommand.RequestSchema = zod_1.z.object({
10
+ uuid: zod_1.z.string().uuid(),
11
+ });
12
+ DeleteHostCommand.ResponseSchema = zod_1.z.object({
13
+ response: zod_1.z.object({
14
+ isDeleted: zod_1.z.boolean(),
15
+ }),
16
+ });
17
+ })(DeleteHostCommand || (exports.DeleteHostCommand = DeleteHostCommand = {}));
@@ -0,0 +1,18 @@
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("./create.command"), exports);
18
+ __exportStar(require("./delete.command"), exports);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetInboundsCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const inbounds_schema_1 = require("../../models/inbounds.schema");
7
+ var GetInboundsCommand;
8
+ (function (GetInboundsCommand) {
9
+ GetInboundsCommand.url = api_1.REST_API.INBOUNDS.GET_INBOUNDS;
10
+ GetInboundsCommand.ResponseSchema = zod_1.z.object({
11
+ response: zod_1.z.array(inbounds_schema_1.InboundsSchema.pick({ tag: true, uuid: true })),
12
+ });
13
+ })(GetInboundsCommand || (exports.GetInboundsCommand = GetInboundsCommand = {}));
@@ -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("./get-inbounds.command"), exports);