@gustavo-valsechi/node 1.0.4 → 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/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { databaseInit } from './src/database/index.mjs';
2
2
  export { apiRouter, mainRouter } from './src/router/index.mjs';
3
3
  export { app, serverInit } from './src/server/index.mjs';
4
- export { OPERATORS, converter, existsOperator, paginate, refactorWhere, responseWrapper } from './src/tools/index.mjs';
4
+ export { OPERATORS, converter, existsOperator, moduler, paginate, refactorWhere, responseWrapper } from './src/tools/index.mjs';
5
5
  import 'typeorm';
6
6
  import 'fastify';
7
7
  import 'http';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { databaseInit } from './src/database/index.js';
2
2
  export { apiRouter, mainRouter } from './src/router/index.js';
3
3
  export { app, serverInit } from './src/server/index.js';
4
- export { OPERATORS, converter, existsOperator, paginate, refactorWhere, responseWrapper } from './src/tools/index.js';
4
+ export { OPERATORS, converter, existsOperator, moduler, paginate, refactorWhere, responseWrapper } from './src/tools/index.js';
5
5
  import 'typeorm';
6
6
  import 'fastify';
7
7
  import 'http';
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  databaseInit: () => databaseInit,
38
38
  existsOperator: () => existsOperator,
39
39
  mainRouter: () => mainRouter,
40
+ moduler: () => moduler,
40
41
  paginate: () => paginate,
41
42
  refactorWhere: () => refactorWhere,
42
43
  responseWrapper: () => responseWrapper,
@@ -67,15 +68,18 @@ var databaseInit = (entities) => {
67
68
  username,
68
69
  password,
69
70
  database,
70
- synchronize: true,
71
+ synchronize: false,
71
72
  migrationsRun: false,
72
73
  logging: "all",
73
74
  logger: "advanced-console",
74
- migrations: [__dirname + "/**/migrations/*{.js,.ts}"],
75
+ migrations: ["src/migrations/*.ts"],
75
76
  applicationName: (0, import_os.hostname)(),
76
77
  entities
77
78
  });
78
- DB.initialize().then(() => console.log("\u{1F680} Data Source has been initialized!")).catch((err) => console.error("\u{1F534} Error during Data Source initialization", err));
79
+ DB.initialize().then(async () => {
80
+ console.log("\u{1F680} Data Source has been initialized!");
81
+ await DB.runMigrations();
82
+ }).catch((err) => console.error("\u{1F534} Error during Data Source initialization", err));
79
83
  return DB;
80
84
  };
81
85
 
@@ -196,6 +200,20 @@ var paginate = async (repository, options) => {
196
200
  };
197
201
  };
198
202
 
203
+ // src/tools/moduler.ts
204
+ var import_path = __toESM(require("path"));
205
+ var import_fs = __toESM(require("fs"));
206
+ var moduler = () => {
207
+ let content = {};
208
+ import_fs.default.readdirSync(__dirname).forEach((file) => {
209
+ if (file === "index.ts" || !file.endsWith(".ts")) return;
210
+ const filePath = import_path.default.join(__dirname, file);
211
+ const module2 = require(filePath);
212
+ content = { ...content, ...module2 };
213
+ });
214
+ return content;
215
+ };
216
+
199
217
  // src/router/health.ts
200
218
  var healthRouter = (router, options, done) => {
201
219
  router.get("/", async (req, res) => {
@@ -276,6 +294,7 @@ var mainRouter = (router, options, done) => {
276
294
  databaseInit,
277
295
  existsOperator,
278
296
  mainRouter,
297
+ moduler,
279
298
  paginate,
280
299
  refactorWhere,
281
300
  responseWrapper,
package/dist/index.mjs CHANGED
@@ -1,3 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
1
8
  // src/database/index.ts
2
9
  import "dotenv/config";
3
10
  import { hostname } from "os";
@@ -21,15 +28,18 @@ var databaseInit = (entities) => {
21
28
  username,
22
29
  password,
23
30
  database,
24
- synchronize: true,
31
+ synchronize: false,
25
32
  migrationsRun: false,
26
33
  logging: "all",
27
34
  logger: "advanced-console",
28
- migrations: [__dirname + "/**/migrations/*{.js,.ts}"],
35
+ migrations: ["src/migrations/*.ts"],
29
36
  applicationName: hostname(),
30
37
  entities
31
38
  });
32
- DB.initialize().then(() => console.log("\u{1F680} Data Source has been initialized!")).catch((err) => console.error("\u{1F534} Error during Data Source initialization", err));
39
+ DB.initialize().then(async () => {
40
+ console.log("\u{1F680} Data Source has been initialized!");
41
+ await DB.runMigrations();
42
+ }).catch((err) => console.error("\u{1F534} Error during Data Source initialization", err));
33
43
  return DB;
34
44
  };
35
45
 
@@ -161,6 +171,20 @@ var paginate = async (repository, options) => {
161
171
  };
162
172
  };
163
173
 
174
+ // src/tools/moduler.ts
175
+ import path from "path";
176
+ import fs from "fs";
177
+ var moduler = () => {
178
+ let content = {};
179
+ fs.readdirSync(__dirname).forEach((file) => {
180
+ if (file === "index.ts" || !file.endsWith(".ts")) return;
181
+ const filePath = path.join(__dirname, file);
182
+ const module = __require(filePath);
183
+ content = { ...content, ...module };
184
+ });
185
+ return content;
186
+ };
187
+
164
188
  // src/router/health.ts
165
189
  var healthRouter = (router, options, done) => {
166
190
  router.get("/", async (req, res) => {
@@ -240,6 +264,7 @@ export {
240
264
  databaseInit,
241
265
  existsOperator,
242
266
  mainRouter,
267
+ moduler,
243
268
  paginate,
244
269
  refactorWhere,
245
270
  responseWrapper,
@@ -45,15 +45,18 @@ var databaseInit = (entities) => {
45
45
  username,
46
46
  password,
47
47
  database,
48
- synchronize: true,
48
+ synchronize: false,
49
49
  migrationsRun: false,
50
50
  logging: "all",
51
51
  logger: "advanced-console",
52
- migrations: [__dirname + "/**/migrations/*{.js,.ts}"],
52
+ migrations: ["src/migrations/*.ts"],
53
53
  applicationName: (0, import_os.hostname)(),
54
54
  entities
55
55
  });
56
- DB.initialize().then(() => console.log("\u{1F680} Data Source has been initialized!")).catch((err) => console.error("\u{1F534} Error during Data Source initialization", err));
56
+ DB.initialize().then(async () => {
57
+ console.log("\u{1F680} Data Source has been initialized!");
58
+ await DB.runMigrations();
59
+ }).catch((err) => console.error("\u{1F534} Error during Data Source initialization", err));
57
60
  return DB;
58
61
  };
59
62
  // Annotate the CommonJS export names for ESM import in node:
@@ -21,15 +21,18 @@ var databaseInit = (entities) => {
21
21
  username,
22
22
  password,
23
23
  database,
24
- synchronize: true,
24
+ synchronize: false,
25
25
  migrationsRun: false,
26
26
  logging: "all",
27
27
  logger: "advanced-console",
28
- migrations: [__dirname + "/**/migrations/*{.js,.ts}"],
28
+ migrations: ["src/migrations/*.ts"],
29
29
  applicationName: hostname(),
30
30
  entities
31
31
  });
32
- DB.initialize().then(() => console.log("\u{1F680} Data Source has been initialized!")).catch((err) => console.error("\u{1F534} Error during Data Source initialization", err));
32
+ DB.initialize().then(async () => {
33
+ console.log("\u{1F680} Data Source has been initialized!");
34
+ await DB.runMigrations();
35
+ }).catch((err) => console.error("\u{1F534} Error during Data Source initialization", err));
33
36
  return DB;
34
37
  };
35
38
  export {
@@ -24,4 +24,6 @@ declare const paginate: (repository: any, options: {
24
24
  content: any;
25
25
  }>;
26
26
 
27
- export { OPERATORS, converter, existsOperator, paginate, refactorWhere, responseWrapper };
27
+ declare const moduler: () => Record<string, any>;
28
+
29
+ export { OPERATORS, converter, existsOperator, moduler, paginate, refactorWhere, responseWrapper };
@@ -24,4 +24,6 @@ declare const paginate: (repository: any, options: {
24
24
  content: any;
25
25
  }>;
26
26
 
27
- export { OPERATORS, converter, existsOperator, paginate, refactorWhere, responseWrapper };
27
+ declare const moduler: () => Record<string, any>;
28
+
29
+ export { OPERATORS, converter, existsOperator, moduler, paginate, refactorWhere, responseWrapper };
@@ -33,6 +33,7 @@ __export(tools_exports, {
33
33
  OPERATORS: () => OPERATORS,
34
34
  converter: () => converter,
35
35
  existsOperator: () => existsOperator,
36
+ moduler: () => moduler,
36
37
  paginate: () => paginate,
37
38
  refactorWhere: () => refactorWhere,
38
39
  responseWrapper: () => responseWrapper
@@ -155,11 +156,26 @@ var paginate = async (repository, options) => {
155
156
  content: data
156
157
  };
157
158
  };
159
+
160
+ // src/tools/moduler.ts
161
+ var import_path = __toESM(require("path"));
162
+ var import_fs = __toESM(require("fs"));
163
+ var moduler = () => {
164
+ let content = {};
165
+ import_fs.default.readdirSync(__dirname).forEach((file) => {
166
+ if (file === "index.ts" || !file.endsWith(".ts")) return;
167
+ const filePath = import_path.default.join(__dirname, file);
168
+ const module2 = require(filePath);
169
+ content = { ...content, ...module2 };
170
+ });
171
+ return content;
172
+ };
158
173
  // Annotate the CommonJS export names for ESM import in node:
159
174
  0 && (module.exports = {
160
175
  OPERATORS,
161
176
  converter,
162
177
  existsOperator,
178
+ moduler,
163
179
  paginate,
164
180
  refactorWhere,
165
181
  responseWrapper
@@ -1,3 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
1
8
  // src/tools/response.ts
2
9
  var responseWrapper = async (res, promise) => {
3
10
  return promise.then((data) => {
@@ -125,10 +132,25 @@ var paginate = async (repository, options) => {
125
132
  content: data
126
133
  };
127
134
  };
135
+
136
+ // src/tools/moduler.ts
137
+ import path from "path";
138
+ import fs from "fs";
139
+ var moduler = () => {
140
+ let content = {};
141
+ fs.readdirSync(__dirname).forEach((file) => {
142
+ if (file === "index.ts" || !file.endsWith(".ts")) return;
143
+ const filePath = path.join(__dirname, file);
144
+ const module = __require(filePath);
145
+ content = { ...content, ...module };
146
+ });
147
+ return content;
148
+ };
128
149
  export {
129
150
  OPERATORS,
130
151
  converter,
131
152
  existsOperator,
153
+ moduler,
132
154
  paginate,
133
155
  refactorWhere,
134
156
  responseWrapper
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/node",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",