backfarm 1.0.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.
Files changed (141) hide show
  1. package/dist/chunk-7QVYU63E.js +7 -0
  2. package/dist/chunk-7QVYU63E.js.map +1 -0
  3. package/dist/chunk-BMPUYKJJ.js +148 -0
  4. package/dist/chunk-BMPUYKJJ.js.map +1 -0
  5. package/dist/chunk-EB35KLDE.js +49 -0
  6. package/dist/chunk-EB35KLDE.js.map +1 -0
  7. package/dist/chunk-EWQYVPOL.js +30 -0
  8. package/dist/chunk-EWQYVPOL.js.map +1 -0
  9. package/dist/chunk-FMCW72HO.js +110 -0
  10. package/dist/chunk-FMCW72HO.js.map +1 -0
  11. package/dist/chunk-GBXVVI2R.js +528 -0
  12. package/dist/chunk-GBXVVI2R.js.map +1 -0
  13. package/dist/chunk-HZ4GLSOO.js +91 -0
  14. package/dist/chunk-HZ4GLSOO.js.map +1 -0
  15. package/dist/chunk-I6VD2JKM.js +72 -0
  16. package/dist/chunk-I6VD2JKM.js.map +1 -0
  17. package/dist/chunk-IN3YY526.js +165 -0
  18. package/dist/chunk-IN3YY526.js.map +1 -0
  19. package/dist/chunk-MEQAHLW6.js +135 -0
  20. package/dist/chunk-MEQAHLW6.js.map +1 -0
  21. package/dist/chunk-MNSQSU7T.js +90 -0
  22. package/dist/chunk-MNSQSU7T.js.map +1 -0
  23. package/dist/chunk-NDJVYPUT.js +61 -0
  24. package/dist/chunk-NDJVYPUT.js.map +1 -0
  25. package/dist/chunk-NMNAPTVV.js +91 -0
  26. package/dist/chunk-NMNAPTVV.js.map +1 -0
  27. package/dist/chunk-P5XJG7OG.js +71 -0
  28. package/dist/chunk-P5XJG7OG.js.map +1 -0
  29. package/dist/chunk-SSFPGDA3.js +73 -0
  30. package/dist/chunk-SSFPGDA3.js.map +1 -0
  31. package/dist/chunk-UWIMSKL5.js +35 -0
  32. package/dist/chunk-UWIMSKL5.js.map +1 -0
  33. package/dist/chunk-W2745SOE.js +38 -0
  34. package/dist/chunk-W2745SOE.js.map +1 -0
  35. package/dist/chunk-X3R3RLXY.js +62 -0
  36. package/dist/chunk-X3R3RLXY.js.map +1 -0
  37. package/dist/engine/cloudBucket/r2Storage.d.ts +5 -0
  38. package/dist/engine/cloudBucket/r2Storage.js +10 -0
  39. package/dist/engine/cloudBucket/r2Storage.js.map +1 -0
  40. package/dist/engine/mondoDb/mongoDB.d.ts +6 -0
  41. package/dist/engine/mondoDb/mongoDB.js +11 -0
  42. package/dist/engine/mondoDb/mongoDB.js.map +1 -0
  43. package/dist/engine/multer/multer_configs.d.ts +6 -0
  44. package/dist/engine/multer/multer_configs.js +11 -0
  45. package/dist/engine/multer/multer_configs.js.map +1 -0
  46. package/dist/engine/server/app.d.ts +5 -0
  47. package/dist/engine/server/app.js +8 -0
  48. package/dist/engine/server/app.js.map +1 -0
  49. package/dist/engine/server/server.d.ts +6 -0
  50. package/dist/engine/server/server.js +17 -0
  51. package/dist/engine/server/server.js.map +1 -0
  52. package/dist/engine/sql/mySql.d.ts +7 -0
  53. package/dist/engine/sql/mySql.js +13 -0
  54. package/dist/engine/sql/mySql.js.map +1 -0
  55. package/dist/engine/sql/pgSql.d.ts +7 -0
  56. package/dist/engine/sql/pgSql.js +13 -0
  57. package/dist/engine/sql/pgSql.js.map +1 -0
  58. package/dist/event-streams-PM4LQKAH.js +993 -0
  59. package/dist/event-streams-PM4LQKAH.js.map +1 -0
  60. package/dist/utility/libs/env.d.ts +24 -0
  61. package/dist/utility/libs/env.js +8 -0
  62. package/dist/utility/libs/env.js.map +1 -0
  63. package/dist/utility/libs/interface.d.ts +114 -0
  64. package/dist/utility/libs/interface.js +1 -0
  65. package/dist/utility/libs/interface.js.map +1 -0
  66. package/dist/utility/libs/types.d.ts +207 -0
  67. package/dist/utility/libs/types.js +6 -0
  68. package/dist/utility/libs/types.js.map +1 -0
  69. package/dist/utility/utilis/cloud_storage/deleteFile.d.ts +9 -0
  70. package/dist/utility/utilis/cloud_storage/deleteFile.js +60 -0
  71. package/dist/utility/utilis/cloud_storage/deleteFile.js.map +1 -0
  72. package/dist/utility/utilis/cloud_storage/deleteFiles.d.ts +9 -0
  73. package/dist/utility/utilis/cloud_storage/deleteFiles.js +89 -0
  74. package/dist/utility/utilis/cloud_storage/deleteFiles.js.map +1 -0
  75. package/dist/utility/utilis/cloud_storage/downloadFile.d.ts +9 -0
  76. package/dist/utility/utilis/cloud_storage/downloadFile.js +74 -0
  77. package/dist/utility/utilis/cloud_storage/downloadFile.js.map +1 -0
  78. package/dist/utility/utilis/cloud_storage/downloadFiles.d.ts +9 -0
  79. package/dist/utility/utilis/cloud_storage/downloadFiles.js +88 -0
  80. package/dist/utility/utilis/cloud_storage/downloadFiles.js.map +1 -0
  81. package/dist/utility/utilis/cloud_storage/s3Client.d.ts +5 -0
  82. package/dist/utility/utilis/cloud_storage/s3Client.js +17 -0
  83. package/dist/utility/utilis/cloud_storage/s3Client.js.map +1 -0
  84. package/dist/utility/utilis/cloud_storage/uploadFile.d.ts +51 -0
  85. package/dist/utility/utilis/cloud_storage/uploadFile.js +14 -0
  86. package/dist/utility/utilis/cloud_storage/uploadFile.js.map +1 -0
  87. package/dist/utility/utilis/cloud_storage/uploadFiles.d.ts +73 -0
  88. package/dist/utility/utilis/cloud_storage/uploadFiles.js +49 -0
  89. package/dist/utility/utilis/cloud_storage/uploadFiles.js.map +1 -0
  90. package/dist/utility/utilis/general/error_handler.d.ts +31 -0
  91. package/dist/utility/utilis/general/error_handler.js +8 -0
  92. package/dist/utility/utilis/general/error_handler.js.map +1 -0
  93. package/dist/utility/utilis/general/file-operations.d.ts +140 -0
  94. package/dist/utility/utilis/general/file-operations.js +19 -0
  95. package/dist/utility/utilis/general/file-operations.js.map +1 -0
  96. package/dist/utility/utilis/general/sqlDb.js.d.ts +151 -0
  97. package/dist/utility/utilis/general/sqlDb.js.js +13 -0
  98. package/dist/utility/utilis/general/sqlDb.js.js.map +1 -0
  99. package/dist/utility/utilis/general/uuids.d.ts +55 -0
  100. package/dist/utility/utilis/general/uuids.js +8 -0
  101. package/dist/utility/utilis/general/uuids.js.map +1 -0
  102. package/dist/utility/utilis/general/web.d.ts +247 -0
  103. package/dist/utility/utilis/general/web.js +13 -0
  104. package/dist/utility/utilis/general/web.js.map +1 -0
  105. package/dist/utility/utilis/mongoDb/buldWrite.d.ts +53 -0
  106. package/dist/utility/utilis/mongoDb/buldWrite.js +32 -0
  107. package/dist/utility/utilis/mongoDb/buldWrite.js.map +1 -0
  108. package/dist/utility/utilis/mongoDb/deleteDocument.d.ts +54 -0
  109. package/dist/utility/utilis/mongoDb/deleteDocument.js +34 -0
  110. package/dist/utility/utilis/mongoDb/deleteDocument.js.map +1 -0
  111. package/dist/utility/utilis/mongoDb/insertField.d.ts +40 -0
  112. package/dist/utility/utilis/mongoDb/insertField.js +33 -0
  113. package/dist/utility/utilis/mongoDb/insertField.js.map +1 -0
  114. package/dist/utility/utilis/mongoDb/insertFields.d.ts +48 -0
  115. package/dist/utility/utilis/mongoDb/insertFields.js +35 -0
  116. package/dist/utility/utilis/mongoDb/insertFields.js.map +1 -0
  117. package/dist/utility/utilis/mongoDb/updateFiled.d.ts +65 -0
  118. package/dist/utility/utilis/mongoDb/updateFiled.js +40 -0
  119. package/dist/utility/utilis/mongoDb/updateFiled.js.map +1 -0
  120. package/dist/utility/utilis/multer/upload_batch.d.ts +7 -0
  121. package/dist/utility/utilis/multer/upload_batch.js +17 -0
  122. package/dist/utility/utilis/multer/upload_batch.js.map +1 -0
  123. package/dist/utility/utilis/multer/upload_single.d.ts +7 -0
  124. package/dist/utility/utilis/multer/upload_single.js +16 -0
  125. package/dist/utility/utilis/multer/upload_single.js.map +1 -0
  126. package/dist/utility/utilis/postgres/executeQuery.d.ts +215 -0
  127. package/dist/utility/utilis/postgres/executeQuery.js +46 -0
  128. package/dist/utility/utilis/postgres/executeQuery.js.map +1 -0
  129. package/dist/utility/utilis/postgres/subSqlfiles/executeMySqlQuery.d.ts +9 -0
  130. package/dist/utility/utilis/postgres/subSqlfiles/executeMySqlQuery.js +10 -0
  131. package/dist/utility/utilis/postgres/subSqlfiles/executeMySqlQuery.js.map +1 -0
  132. package/dist/utility/utilis/postgres/subSqlfiles/executePgQuery.d.ts +11 -0
  133. package/dist/utility/utilis/postgres/subSqlfiles/executePgQuery.js +12 -0
  134. package/dist/utility/utilis/postgres/subSqlfiles/executePgQuery.js.map +1 -0
  135. package/dist/utility/utilis/server/app.d.ts +5 -0
  136. package/dist/utility/utilis/server/app.js +15 -0
  137. package/dist/utility/utilis/server/app.js.map +1 -0
  138. package/dist/utility/utilis/server/server.d.ts +5 -0
  139. package/dist/utility/utilis/server/server.js +24 -0
  140. package/dist/utility/utilis/server/server.js.map +1 -0
  141. package/package.json +55 -0
@@ -0,0 +1,215 @@
1
+ import * as mysql from 'mysql2/promise';
2
+ import * as pg from 'pg';
3
+ import { QueryItems } from '../../libs/interface.js';
4
+ import 'mongodb';
5
+ import '../../libs/types.js';
6
+ import 'express';
7
+ import '../../libs/env.js';
8
+
9
+ /**
10
+ * Executes one or more SQL queries using the database configured through
11
+ * the `SQL_DB_URL` environment variable.
12
+ *
13
+ * The function automatically detects whether the configured database is
14
+ * PostgreSQL or MySQL and delegates execution to the appropriate database
15
+ * implementation.
16
+ *
17
+ * Supports structured CRUD operations (`insert_one`, `insert_many`, `select`,
18
+ * `update`, and `delete`) as well as custom raw SQL queries.
19
+ *
20
+ * Parameterized conditions and raw queries are supported. The placeholder
21
+ * syntax must match the configured database engine:
22
+ *
23
+ * - MySQL uses `?` placeholders.
24
+ * - PostgreSQL uses `$1`, `$2`, `$3`, etc.
25
+ *
26
+ * The corresponding values are supplied through `conditionalParams` for
27
+ * structured CRUD operations or `params` for raw SQL queries.
28
+ *
29
+ * @param query - The SQL operations to execute.
30
+ * @param query.crud - Optional array of structured CRUD operations.
31
+ * @param query.custom - Optional raw SQL query or array of raw SQL queries.
32
+ *
33
+ * @returns A promise resolving to the result returned by the PostgreSQL or
34
+ * MySQL query executor. If the configured `SQL_DB_URL` does not represent a
35
+ * supported database, an `Error` is returned.
36
+ *
37
+ * @example
38
+ * // Insert a user.
39
+ * //
40
+ * // This operation is database-independent because the values are passed
41
+ * // as an object and the underlying executor generates the appropriate SQL.
42
+ * await executeQuery({
43
+ * crud: [
44
+ * {
45
+ * insert_one: {
46
+ * table: CONSTANTS.USER_INFOS,
47
+ * item: {
48
+ * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),
49
+ * [CONSTANTS.USER_NAME]: 'Divyanshu',
50
+ * [CONSTANTS.USER_EMAIL]: 'div@example.com',
51
+ * [CONSTANTS.USER_GENDER]: CONSTANTS.GENDER_TYPE.MALE,
52
+ * },
53
+ * },
54
+ * },
55
+ * ],
56
+ * });
57
+ *
58
+ * @example
59
+ * // Select a user by email.
60
+ * //
61
+ * // MySQL:
62
+ * // condition: 'user_email = ?'
63
+ * //
64
+ * // PostgreSQL:
65
+ * // condition: 'user_email = $1'
66
+ * //
67
+ * // The value is supplied separately through conditionalParams.
68
+ * await executeQuery({
69
+ * crud: [
70
+ * {
71
+ * select: {
72
+ * table: CONSTANTS.USER_INFOS,
73
+ * columns: [
74
+ * CONSTANTS.USER_PRIMARY_ID,
75
+ * CONSTANTS.USER_NAME,
76
+ * CONSTANTS.USER_EMAIL,
77
+ * ],
78
+ * condition: 'user_email = ?',
79
+ * conditionalParams: ['div@example.com'],
80
+ * },
81
+ * },
82
+ * ],
83
+ * });
84
+ *
85
+ * @example
86
+ * // Update a user's information.
87
+ * //
88
+ * // MySQL:
89
+ * // condition: 'user_primary_id = ?'
90
+ * //
91
+ * // PostgreSQL:
92
+ * // condition: 'user_primary_id = $1'
93
+ * await executeQuery({
94
+ * crud: [
95
+ * {
96
+ * update: {
97
+ * table: CONSTANTS.USER_INFOS,
98
+ * item: {
99
+ * [CONSTANTS.USER_NAME]: 'Div',
100
+ * [CONSTANTS.USER_PHONE_NUMBER]: '+1234567890',
101
+ * },
102
+ * condition: 'user_primary_id = ?',
103
+ * conditionalParams: [
104
+ * '550e8400-e29b-41d4-a716-446655440000',
105
+ * ],
106
+ * },
107
+ * },
108
+ * ],
109
+ * });
110
+ *
111
+ * @example
112
+ * // Delete a user.
113
+ * //
114
+ * // Replace `?` with `$1` when using PostgreSQL.
115
+ * await executeQuery({
116
+ * crud: [
117
+ * {
118
+ * delete: {
119
+ * table: CONSTANTS.USER_INFOS,
120
+ * condition: 'user_primary_id = ?',
121
+ * conditionalParams: [
122
+ * '550e8400-e29b-41d4-a716-446655440000',
123
+ * ],
124
+ * },
125
+ * },
126
+ * ],
127
+ * });
128
+ *
129
+ * @example
130
+ * // Execute a raw SQL query.
131
+ * //
132
+ * // MySQL:
133
+ * // query: 'SELECT * FROM user_infos WHERE user_email = ?'
134
+ * //
135
+ * // PostgreSQL:
136
+ * // query: 'SELECT * FROM user_infos WHERE user_email = $1'
137
+ * await executeQuery({
138
+ * custom: {
139
+ * query: 'SELECT * FROM user_infos WHERE user_email = ?',
140
+ * params: ['div@example.com'],
141
+ * },
142
+ * });
143
+ *
144
+ * @example
145
+ * // Execute multiple operations in one call.
146
+ * //
147
+ * // The underlying executor handles the operations according to the
148
+ * // configured database engine.
149
+ * await executeQuery({
150
+ * crud: [
151
+ * {
152
+ * insert_one: {
153
+ * table: CONSTANTS.USER_INFOS,
154
+ * item: {
155
+ * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),
156
+ * [CONSTANTS.USER_NAME]: 'Alice',
157
+ * [CONSTANTS.USER_EMAIL]: 'alice@example.com',
158
+ * },
159
+ * },
160
+ * },
161
+ * {
162
+ * update: {
163
+ * table: CONSTANTS.USER_INFOS,
164
+ * item: {
165
+ * status: 'active',
166
+ * },
167
+ * condition: 'user_email = ?',
168
+ * conditionalParams: ['alice@example.com'],
169
+ * },
170
+ * },
171
+ * ],
172
+ * });
173
+ */
174
+ declare const executeQuery: (query: QueryItems) => Promise<any[] | Error>;
175
+ /**
176
+ * Returns the connection pool for the SQL database configured through
177
+ * the `SQL_DB_URL` environment variable.
178
+ *
179
+ * The database type is detected automatically from the connection URL.
180
+ * If the URL represents a PostgreSQL database, the PostgreSQL connection
181
+ * pool is returned. If it represents a MySQL database, the MySQL connection
182
+ * pool is returned.
183
+ *
184
+ * This function acts as the database-agnostic entry point for obtaining
185
+ * the application's SQL connection pool. Callers do not need to know
186
+ * whether the application is currently using PostgreSQL or MySQL.
187
+ *
188
+ * The underlying pool is created lazily and reused across subsequent
189
+ * calls through `getPgSqlPool()` or `getMySqlPool()`.
190
+ *
191
+ * @returns A promise resolving to the PostgreSQL or MySQL connection pool,
192
+ * depending on the configured `SQL_DB_URL`. Returns `undefined` if the
193
+ * configured database URL does not match a supported SQL database.
194
+ *
195
+ * @example
196
+ * // Get the configured SQL connection pool.
197
+ * const pool = await getPool();
198
+ *
199
+ * if (!pool) {
200
+ * throw new Error('Unsupported SQL database configuration.');
201
+ * }
202
+ *
203
+ * @example
204
+ * // The same function works regardless of whether the application
205
+ * // is configured to use PostgreSQL or MySQL.
206
+ * const pool = await getPool();
207
+ *
208
+ * if (pool) {
209
+ * // Use the returned pool with the appropriate database layer.
210
+ * console.log('Database pool is ready.');
211
+ * }
212
+ */
213
+ declare const getPool: () => Promise<pg.Pool | mysql.Pool | undefined>;
214
+
215
+ export { executeQuery, getPool };
@@ -0,0 +1,46 @@
1
+ import {
2
+ executeMySqlQuery
3
+ } from "../../../chunk-BMPUYKJJ.js";
4
+ import {
5
+ executePgSqlQuery
6
+ } from "../../../chunk-MEQAHLW6.js";
7
+ import {
8
+ isMySQL,
9
+ isPostgreSQL
10
+ } from "../../../chunk-MNSQSU7T.js";
11
+ import {
12
+ getMySqlPool
13
+ } from "../../../chunk-HZ4GLSOO.js";
14
+ import {
15
+ getPgSqlPool
16
+ } from "../../../chunk-NMNAPTVV.js";
17
+ import {
18
+ ENV
19
+ } from "../../../chunk-EWQYVPOL.js";
20
+ import {
21
+ __name
22
+ } from "../../../chunk-7QVYU63E.js";
23
+
24
+ // src/utility/utilis/postgres/executeQuery.ts
25
+ var executeQuery = /* @__PURE__ */ __name(async (query) => {
26
+ if (isPostgreSQL(ENV.SQL_DB_URL)) {
27
+ return await executePgSqlQuery(query);
28
+ } else if (isMySQL(ENV.SQL_DB_URL)) {
29
+ return await executeMySqlQuery(query);
30
+ } else {
31
+ return new Error(`Unable to execute query. Please check the SQL_DB_URL in .env file and the db.sql file.`);
32
+ }
33
+ }, "executeQuery");
34
+ var getPool = /* @__PURE__ */ __name(async () => {
35
+ if (isPostgreSQL(ENV.SQL_DB_URL)) {
36
+ return getPgSqlPool();
37
+ }
38
+ if (isMySQL(ENV.SQL_DB_URL)) {
39
+ return getMySqlPool();
40
+ }
41
+ }, "getPool");
42
+ export {
43
+ executeQuery,
44
+ getPool
45
+ };
46
+ //# sourceMappingURL=executeQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utility/utilis/postgres/executeQuery.ts"],"sourcesContent":["import type {QueryItems} from \"../../libs/interface.js\";\r\nimport {isMySQL, isPostgreSQL} from \"../general/sqlDb.js.js\";\r\nimport {ENV} from \"../../libs/env.js\";\r\nimport {executePgSqlQuery} from \"./subSqlfiles/executePgQuery.js\";\r\nimport {executeMySqlQuery} from \"./subSqlfiles/executeMySqlQuery.js\";\r\nimport {getMySqlPool} from \"../../../engine/sql/mySql.js\";\r\nimport {getPgSqlPool} from \"../../../engine/sql/pgSql.js\";\r\n\r\n\r\n\r\n\r\n/**\r\n * Executes one or more SQL queries using the database configured through\r\n * the `SQL_DB_URL` environment variable.\r\n *\r\n * The function automatically detects whether the configured database is\r\n * PostgreSQL or MySQL and delegates execution to the appropriate database\r\n * implementation.\r\n *\r\n * Supports structured CRUD operations (`insert_one`, `insert_many`, `select`,\r\n * `update`, and `delete`) as well as custom raw SQL queries.\r\n *\r\n * Parameterized conditions and raw queries are supported. The placeholder\r\n * syntax must match the configured database engine:\r\n *\r\n * - MySQL uses `?` placeholders.\r\n * - PostgreSQL uses `$1`, `$2`, `$3`, etc.\r\n *\r\n * The corresponding values are supplied through `conditionalParams` for\r\n * structured CRUD operations or `params` for raw SQL queries.\r\n *\r\n * @param query - The SQL operations to execute.\r\n * @param query.crud - Optional array of structured CRUD operations.\r\n * @param query.custom - Optional raw SQL query or array of raw SQL queries.\r\n *\r\n * @returns A promise resolving to the result returned by the PostgreSQL or\r\n * MySQL query executor. If the configured `SQL_DB_URL` does not represent a\r\n * supported database, an `Error` is returned.\r\n *\r\n * @example\r\n * // Insert a user.\r\n * //\r\n * // This operation is database-independent because the values are passed\r\n * // as an object and the underlying executor generates the appropriate SQL.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * insert_one: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),\r\n * [CONSTANTS.USER_NAME]: 'Divyanshu',\r\n * [CONSTANTS.USER_EMAIL]: 'div@example.com',\r\n * [CONSTANTS.USER_GENDER]: CONSTANTS.GENDER_TYPE.MALE,\r\n * },\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Select a user by email.\r\n * //\r\n * // MySQL:\r\n * // condition: 'user_email = ?'\r\n * //\r\n * // PostgreSQL:\r\n * // condition: 'user_email = $1'\r\n * //\r\n * // The value is supplied separately through conditionalParams.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * select: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * columns: [\r\n * CONSTANTS.USER_PRIMARY_ID,\r\n * CONSTANTS.USER_NAME,\r\n * CONSTANTS.USER_EMAIL,\r\n * ],\r\n * condition: 'user_email = ?',\r\n * conditionalParams: ['div@example.com'],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Update a user's information.\r\n * //\r\n * // MySQL:\r\n * // condition: 'user_primary_id = ?'\r\n * //\r\n * // PostgreSQL:\r\n * // condition: 'user_primary_id = $1'\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * update: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * [CONSTANTS.USER_NAME]: 'Div',\r\n * [CONSTANTS.USER_PHONE_NUMBER]: '+1234567890',\r\n * },\r\n * condition: 'user_primary_id = ?',\r\n * conditionalParams: [\r\n * '550e8400-e29b-41d4-a716-446655440000',\r\n * ],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Delete a user.\r\n * //\r\n * // Replace `?` with `$1` when using PostgreSQL.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * delete: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * condition: 'user_primary_id = ?',\r\n * conditionalParams: [\r\n * '550e8400-e29b-41d4-a716-446655440000',\r\n * ],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Execute a raw SQL query.\r\n * //\r\n * // MySQL:\r\n * // query: 'SELECT * FROM user_infos WHERE user_email = ?'\r\n * //\r\n * // PostgreSQL:\r\n * // query: 'SELECT * FROM user_infos WHERE user_email = $1'\r\n * await executeQuery({\r\n * custom: {\r\n * query: 'SELECT * FROM user_infos WHERE user_email = ?',\r\n * params: ['div@example.com'],\r\n * },\r\n * });\r\n *\r\n * @example\r\n * // Execute multiple operations in one call.\r\n * //\r\n * // The underlying executor handles the operations according to the\r\n * // configured database engine.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * insert_one: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),\r\n * [CONSTANTS.USER_NAME]: 'Alice',\r\n * [CONSTANTS.USER_EMAIL]: 'alice@example.com',\r\n * },\r\n * },\r\n * },\r\n * {\r\n * update: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * status: 'active',\r\n * },\r\n * condition: 'user_email = ?',\r\n * conditionalParams: ['alice@example.com'],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n */\r\nexport const executeQuery = async (query: QueryItems) => {\r\n\r\n if (isPostgreSQL(ENV.SQL_DB_URL)) {\r\n return await executePgSqlQuery(query)\r\n }\r\n else if (isMySQL(ENV.SQL_DB_URL)) {\r\n return await executeMySqlQuery(query)\r\n }\r\n else {\r\n return new Error(`Unable to execute query. Please check the SQL_DB_URL in .env file and the db.sql file.`);\r\n }\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Returns the connection pool for the SQL database configured through\r\n * the `SQL_DB_URL` environment variable.\r\n *\r\n * The database type is detected automatically from the connection URL.\r\n * If the URL represents a PostgreSQL database, the PostgreSQL connection\r\n * pool is returned. If it represents a MySQL database, the MySQL connection\r\n * pool is returned.\r\n *\r\n * This function acts as the database-agnostic entry point for obtaining\r\n * the application's SQL connection pool. Callers do not need to know\r\n * whether the application is currently using PostgreSQL or MySQL.\r\n *\r\n * The underlying pool is created lazily and reused across subsequent\r\n * calls through `getPgSqlPool()` or `getMySqlPool()`.\r\n *\r\n * @returns A promise resolving to the PostgreSQL or MySQL connection pool,\r\n * depending on the configured `SQL_DB_URL`. Returns `undefined` if the\r\n * configured database URL does not match a supported SQL database.\r\n *\r\n * @example\r\n * // Get the configured SQL connection pool.\r\n * const pool = await getPool();\r\n *\r\n * if (!pool) {\r\n * throw new Error('Unsupported SQL database configuration.');\r\n * }\r\n *\r\n * @example\r\n * // The same function works regardless of whether the application\r\n * // is configured to use PostgreSQL or MySQL.\r\n * const pool = await getPool();\r\n *\r\n * if (pool) {\r\n * // Use the returned pool with the appropriate database layer.\r\n * console.log('Database pool is ready.');\r\n * }\r\n */\r\nexport const getPool = async () => {\r\n if (isPostgreSQL(ENV.SQL_DB_URL)) {\r\n return getPgSqlPool()\r\n }\r\n if (isMySQL(ENV.SQL_DB_URL)) {\r\n return getMySqlPool()\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgLO,IAAM,eAAe,8BAAO,UAAsB;AAErD,MAAI,aAAa,IAAI,UAAU,GAAG;AAC9B,WAAO,MAAM,kBAAkB,KAAK;AAAA,EACxC,WACS,QAAQ,IAAI,UAAU,GAAG;AAC9B,WAAO,MAAM,kBAAkB,KAAK;AAAA,EACxC,OACK;AACD,WAAO,IAAI,MAAM,wFAAwF;AAAA,EAC7G;AAEJ,GAZ4B;AAwDrB,IAAM,UAAU,mCAAY;AAC/B,MAAI,aAAa,IAAI,UAAU,GAAG;AAC9B,WAAO,aAAa;AAAA,EACxB;AACA,MAAI,QAAQ,IAAI,UAAU,GAAG;AACzB,WAAO,aAAa;AAAA,EACxB;AACJ,GAPuB;","names":[]}
@@ -0,0 +1,9 @@
1
+ import { QueryItems } from '../../../libs/interface.js';
2
+ import 'mongodb';
3
+ import '../../../libs/types.js';
4
+ import 'express';
5
+ import '../../../libs/env.js';
6
+
7
+ declare const executeMySqlQuery: (query: QueryItems) => Promise<any[]>;
8
+
9
+ export { executeMySqlQuery };
@@ -0,0 +1,10 @@
1
+ import {
2
+ executeMySqlQuery
3
+ } from "../../../../chunk-BMPUYKJJ.js";
4
+ import "../../../../chunk-HZ4GLSOO.js";
5
+ import "../../../../chunk-EWQYVPOL.js";
6
+ import "../../../../chunk-7QVYU63E.js";
7
+ export {
8
+ executeMySqlQuery
9
+ };
10
+ //# sourceMappingURL=executeMySqlQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,11 @@
1
+ import { PoolClient } from 'pg';
2
+ import { QueryItems } from '../../../libs/interface.js';
3
+ import { SqlRawQuery } from '../../../libs/types.js';
4
+ import 'mongodb';
5
+ import 'express';
6
+ import '../../../libs/env.js';
7
+
8
+ declare const executePgSqlQuery: (query: QueryItems) => Promise<any[]>;
9
+ declare const executeCustom: (customQuery: SqlRawQuery | SqlRawQuery[], poolClient?: PoolClient | null) => Promise<any[]>;
10
+
11
+ export { executeCustom, executePgSqlQuery };
@@ -0,0 +1,12 @@
1
+ import {
2
+ executeCustom,
3
+ executePgSqlQuery
4
+ } from "../../../../chunk-MEQAHLW6.js";
5
+ import "../../../../chunk-NMNAPTVV.js";
6
+ import "../../../../chunk-EWQYVPOL.js";
7
+ import "../../../../chunk-7QVYU63E.js";
8
+ export {
9
+ executeCustom,
10
+ executePgSqlQuery
11
+ };
12
+ //# sourceMappingURL=executePgQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,5 @@
1
+ import * as express from 'express';
2
+
3
+ declare const getApp: () => express.Application;
4
+
5
+ export { getApp };
@@ -0,0 +1,15 @@
1
+ import {
2
+ app_default
3
+ } from "../../../chunk-W2745SOE.js";
4
+ import {
5
+ __name
6
+ } from "../../../chunk-7QVYU63E.js";
7
+
8
+ // src/utility/utilis/server/app.ts
9
+ var getApp = /* @__PURE__ */ __name(() => {
10
+ return app_default;
11
+ }, "getApp");
12
+ export {
13
+ getApp
14
+ };
15
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utility/utilis/server/app.ts"],"sourcesContent":["import EXPRESS_APP from \"../../../engine/server/app.js\";\r\n\r\nexport const getApp = () => {\r\n return EXPRESS_APP;\r\n}\r\n"],"mappings":";;;;;;;;AAEO,IAAM,SAAS,6BAAM;AACxB,SAAO;AACX,GAFsB;","names":[]}
@@ -0,0 +1,5 @@
1
+ import * as http from 'node:http';
2
+
3
+ declare const getServer: () => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
4
+
5
+ export { getServer };
@@ -0,0 +1,24 @@
1
+ import {
2
+ HTTP_SERVER,
3
+ startServer
4
+ } from "../../../chunk-NDJVYPUT.js";
5
+ import "../../../chunk-W2745SOE.js";
6
+ import "../../../chunk-P5XJG7OG.js";
7
+ import "../../../chunk-MNSQSU7T.js";
8
+ import "../../../chunk-HZ4GLSOO.js";
9
+ import "../../../chunk-NMNAPTVV.js";
10
+ import "../../../chunk-EB35KLDE.js";
11
+ import "../../../chunk-EWQYVPOL.js";
12
+ import {
13
+ __name
14
+ } from "../../../chunk-7QVYU63E.js";
15
+
16
+ // src/utility/utilis/server/server.ts
17
+ await startServer();
18
+ var getServer = /* @__PURE__ */ __name(() => {
19
+ return HTTP_SERVER;
20
+ }, "getServer");
21
+ export {
22
+ getServer
23
+ };
24
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utility/utilis/server/server.ts"],"sourcesContent":["import {HTTP_SERVER, startServer} from \"../../../engine/server/server.js\";\r\n\r\n\r\nawait startServer();\r\n\r\n\r\nexport const getServer = () => {return HTTP_SERVER}\r\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,MAAM,YAAY;AAGX,IAAM,YAAa,6BAAO;AAAC,SAAO;AAAW,GAA1B;","names":[]}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "backfarm",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "keywords": [],
6
+ "author": "Divyanshu Jha",
7
+ "license": "ISC",
8
+ "type": "module",
9
+ "scripts": {
10
+ "sp": "powershell -ExecutionPolicy Bypass -File script/sprel-run.ps1",
11
+ "dev": "tsx watch src/utility/utilis/server/server.ts",
12
+ "build": "tsup",
13
+ "prepublishOnly": "npm run build",
14
+ "start": "node dist/server.js",
15
+ "test": "echo \"Error: no test specified\" && exit 1"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "exports": {
21
+ "./*": {
22
+ "types": "./dist/utility/*.d.ts",
23
+ "import": "./dist/utility/*.js",
24
+ "require": "./dist/utility/*.js"
25
+ }
26
+ },
27
+
28
+ "dependencies": {
29
+ "@aws-sdk/client-s3": "^3.1080.0",
30
+ "dotenv": "^17.4.2",
31
+ "express": "^5.2.1",
32
+ "mongodb": "^7.4.0",
33
+ "multer": "^2.2.0",
34
+ "mysql2": "^3.23.3",
35
+ "p-limit": "^7.3.1",
36
+ "pg": "^8.22.0",
37
+ "swagger-ui-express": "^5.0.1",
38
+ "yamljs": "^0.3.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/express": "^5.0.6",
42
+ "@types/mime-types": "^3.0.1",
43
+ "@types/mongodb": "^4.0.6",
44
+ "@types/multer": "^2.2.0",
45
+ "@types/node": "^26.2.0",
46
+ "@types/pg": "^8.21.0",
47
+ "@types/swagger-ui-express": "^4.1.8",
48
+ "@types/ws": "^8.18.1",
49
+ "@types/yamljs": "^0.2.34",
50
+ "ts-node": "^10.9.2",
51
+ "tsup": "^8.5.1",
52
+ "tsx": "^4.23.0",
53
+ "typescript": "^6.0.3"
54
+ }
55
+ }