zyket 1.0.55 → 1.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zyket",
3
- "version": "1.0.55",
3
+ "version": "1.1.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -31,6 +31,7 @@
31
31
  "redis": "^5.9.0",
32
32
  "sequelize": "^6.37.7",
33
33
  "socket.io": "^4.8.1",
34
+ "sqlite3": "^6.0.1",
34
35
  "swagger-jsdoc": "^6.2.8",
35
36
  "swagger-ui-express": "^5.0.1",
36
37
  "umzug": "^3.8.2"
@@ -22,17 +22,36 @@ module.exports = class Database extends Service {
22
22
 
23
23
  async boot() {
24
24
  this.#createModelsFolder();
25
- this.sequelize = new Sequelize(this.#databaseUrl, {
26
- dialect: process.env.DATABASE_DIALECT || 'mariadb',
25
+ const dialect = process.env.DATABASE_DIALECT || 'mariadb';
26
+ const options = {
27
+ dialect,
27
28
  logging: (msg) => this.#container.get('logger').debug(msg),
28
29
  operatorsAliases: 0,
29
- pool: {
30
+ };
31
+
32
+ // SQLite doesn't support connection pooling
33
+ if (dialect !== 'sqlite') {
34
+ options.pool = {
30
35
  max: 40,
31
36
  min: 0,
32
37
  acquire: 30000,
33
38
  idle: 10000
34
- },
35
- });
39
+ };
40
+ }
41
+
42
+ // For SQLite, handle storage option
43
+ if (dialect === 'sqlite') {
44
+ // If using sqlite dialect, the database URL should be a file path
45
+ // or ':memory:' for in-memory database
46
+ this.sequelize = new Sequelize({
47
+ dialect: 'sqlite',
48
+ storage: this.#databaseUrl.replace('sqlite://', '') || ':memory:',
49
+ logging: (msg) => this.#container.get('logger').debug(msg),
50
+ operatorsAliases: 0,
51
+ });
52
+ } else {
53
+ this.sequelize = new Sequelize(this.#databaseUrl, options);
54
+ }
36
55
 
37
56
  await this.sequelize.authenticate();
38
57