sequelize-game-bank 3.0.1 → 3.0.2
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/database/config/init-db.js +35 -0
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const { Sequelize } = require('sequelize');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const dbDir = path.resolve(__dirname, '..');
|
|
5
|
+
const dbPath = path.join(dbDir, 'citybank.db');
|
|
6
|
+
const logger = require("custom-color-logs").print;
|
|
7
|
+
if (!fs.existsSync(dbDir)) {
|
|
8
|
+
fs.mkdirSync(dbDir, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
if (fs.existsSync(dbPath)) {
|
|
12
|
+
const stats = fs.statSync(dbPath);
|
|
13
|
+
if (stats.size === 0) {
|
|
14
|
+
console.log(logger.DatabaseWarn("База данных пуста или повреждена!"))
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.log(logger.DatabaseError("Файл бд не найден или повреждён."))
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const sequelize = new Sequelize({
|
|
22
|
+
dialect: 'sqlite',
|
|
23
|
+
storage: dbPath,
|
|
24
|
+
logging: false,
|
|
25
|
+
define: {
|
|
26
|
+
timestamps: true
|
|
27
|
+
},
|
|
28
|
+
/*dialectOptions:{
|
|
29
|
+
mode: 2,
|
|
30
|
+
},*/
|
|
31
|
+
retry:{
|
|
32
|
+
max: 5,
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
module.exports = sequelize;
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const path = require("path")
|
|
|
5
5
|
const express = require('express');
|
|
6
6
|
const cookieParser = require('cookie-parser');
|
|
7
7
|
const bcrypt = require('bcrypt');
|
|
8
|
-
const sequelize =
|
|
8
|
+
const sequelize = require(path.join(__dirname, 'database', 'config', 'init-db.js'));
|
|
9
9
|
const User = require(path.join(__dirname, 'database', 'models', 'User.js'));
|
|
10
10
|
const { writeTemplatesIfNotExist } = require(path.join(__dirname, 'database', 'services', 'bot', 'write.js'));
|
|
11
11
|
const registerRoutes = require(path.join(__dirname, 'server', 'server.js'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sequelize-game-bank",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "A Sequelize-based gaming economy and banking system featuring user profiles, credits, admin management, and detailed transaction history.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|