sequelize-game-bank 1.0.1 → 1.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.
Files changed (41) hide show
  1. package/README.md +4 -0
  2. package/database/models/Account.js +2 -1
  3. package/database/models/Credit.js +3 -2
  4. package/database/models/Transaction.js +2 -1
  5. package/database/models/User.js +3 -2
  6. package/database/services/account/add-manny.js +3 -2
  7. package/database/services/account/change-pincode.js +2 -1
  8. package/database/services/account/change-status.js +3 -2
  9. package/database/services/account/create-credit.js +4 -3
  10. package/database/services/account/create.js +2 -1
  11. package/database/services/account/delete.js +2 -1
  12. package/database/services/account/logs.js +3 -2
  13. package/database/services/account/remove-manny.js +3 -2
  14. package/database/services/account/transfer.js +6 -5
  15. package/database/services/bot/cron-schedule.js +6 -5
  16. package/database/services/bot/generators/ban-bot.html +1 -0
  17. package/database/services/bot/generators/ban-bot.txt +1 -0
  18. package/database/services/bot/generators/disable-2FA-bot.html +1 -0
  19. package/database/services/bot/generators/disable-2FA-bot.txt +1 -0
  20. package/database/services/bot/generators/enable-2FA-bot.html +1 -0
  21. package/database/services/bot/generators/enable-2FA-bot.txt +1 -0
  22. package/database/services/bot/generators/login-bot.html +1 -0
  23. package/database/services/bot/generators/login-bot.txt +1 -0
  24. package/database/services/bot/generators/register-bot.html +1 -0
  25. package/database/services/bot/generators/register-bot.txt +7 -0
  26. package/database/services/bot/generators/transfer-from-bot.html +1 -0
  27. package/database/services/bot/generators/transfer-from-bot.txt +1 -0
  28. package/database/services/bot/generators/transfer-to-bot.html +1 -0
  29. package/database/services/bot/generators/transfer-to-bot.txt +1 -0
  30. package/database/services/bot/generators/unban-bot.html +1 -0
  31. package/database/services/bot/generators/unban-bot.txt +1 -0
  32. package/database/services/user/change-password.js +2 -1
  33. package/database/services/user/create.js +2 -1
  34. package/database/services/user/delete.js +2 -1
  35. package/database/services/user/disable-2FA.js +3 -2
  36. package/database/services/user/enable-2FA.js +3 -2
  37. package/database/services/user/login.js +3 -2
  38. package/database/services/user/math-manny.js +2 -1
  39. package/index.js +12 -11
  40. package/package.json +2 -2
  41. package/server/server.js +5 -5
package/README.md CHANGED
@@ -36,5 +36,9 @@ const app = (async function initBank(){
36
36
  }
37
37
  })();
38
38
 
39
+ /**
40
+ * вызов функции BANK() возращает готовый express
41
+ */
42
+
39
43
  // Далее ваш код
40
44
  ```
@@ -1,6 +1,7 @@
1
1
  const { DataTypes } = require('sequelize');
2
2
  const sequelize = require('../config/init-db');
3
- const User = require('./User');
3
+ const path = require("path");
4
+ const User = require(path.join(__dirname, 'User'));
4
5
  const Account = sequelize.define('account', {
5
6
  id: {
6
7
  type: DataTypes.INTEGER,
@@ -1,6 +1,7 @@
1
1
  const { DataTypes } = require('sequelize');
2
- const sequelize = require('../config/init-db');
3
- const Account = require('./Account');
2
+ const path = require("path");
3
+ const sequelize = require(path.join(__dirname, '..', 'config', 'init-db'));
4
+ const Account = require(path.join(__dirname, 'Account'));
4
5
  const Credit = sequelize.define('credit', {
5
6
  id: {
6
7
  type: DataTypes.INTEGER,
@@ -1,5 +1,6 @@
1
1
  const { DataTypes } = require('sequelize');
2
- const sequelize = require('../config/init-db');
2
+ const path = require("path");
3
+ const sequelize = require(path.join(__dirname, '..', 'config', 'init-db'));
3
4
  module.exports = sequelize.define('transaction_log', {
4
5
  id: {
5
6
  type: DataTypes.INTEGER,
@@ -1,5 +1,6 @@
1
1
  const { DataTypes } = require('sequelize');
2
- const sequelize = require('../config/init-db');
2
+ const path = require("path");
3
+ const sequelize = require(path.join(__dirname, '..', 'config', 'init-db'));
3
4
  const User = sequelize.define('user', {
4
5
  name: {
5
6
  type: DataTypes.STRING,
@@ -41,7 +42,7 @@ const User = sequelize.define('user', {
41
42
  avatar: {
42
43
  type: DataTypes.STRING,
43
44
  allowNull: true,
44
- defaultValue: '/uploads/avatars/default.png'
45
+ defaultValue: path.join(__dirname, '..', '..', 'uploads', 'avatars', 'default.png')
45
46
  }
46
47
  });
47
48
  module.exports = User;
@@ -1,5 +1,6 @@
1
- const Account = require('../../models/Account');
2
- const Transaction = require('../../models/Transaction');
1
+ const path = require("path");
2
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
3
+ const Transaction = require(path.join(__dirname, '..', '..', 'models', 'Transaction'));
3
4
  module.exports = async function addManny(accountId, amount) {
4
5
  try {
5
6
  const acc = await Account.findByPk(accountId);
@@ -1,5 +1,6 @@
1
1
  const bcrypt = require('bcrypt');
2
- const Account = require('../../models/Account');
2
+ const path = require("path");
3
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
3
4
  module.exports = async function changePincode(accountId, oldPin, newPin) {
4
5
  try {
5
6
  const acc = await Account.findByPk(accountId);
@@ -1,5 +1,6 @@
1
- const Account = require('../../models/Account');
2
- const { sendBotNotification } = require('../bot/bot');
1
+ const path = require("path");
2
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
3
+ const { sendBotNotification } = require(path.join(__dirname, '..', 'bot', 'bot'));
3
4
  module.exports = async function changeAccountStatus(accountId, isActive) {
4
5
  try {
5
6
  const [updatedCount] = await Account.update(
@@ -1,6 +1,7 @@
1
- const Account = require('./../../models/Account');
2
- const Credit = require('./../../models/Credit');
3
- const sequelize = require('./../../config/init-db');
1
+ const path = require("path");
2
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
3
+ const Credit = require(path.join(__dirname, '..', '..', 'models', 'Credit'));
4
+ const sequelize = require(path.join(__dirname, '..', '..', 'config', 'init-db'));
4
5
  async function createCredit({ accountId, amount, autoRepay = false, rate = 0.1, termMonths = 12 }) {
5
6
  const numericAmount = parseFloat(amount);
6
7
  const numericRate = parseFloat(rate);
@@ -1,5 +1,6 @@
1
1
  const bcrypt = require('bcrypt');
2
- const Account = require('../../models/Account');
2
+ const path = require("path");
3
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
3
4
  module.exports = async function createAccount(username, pinCode, enable2FA) {
4
5
  try {
5
6
  if (!pinCode || pinCode.length > 8) {
@@ -1,4 +1,5 @@
1
- const Account = require('../../models/Account');
1
+ const path = require("path");
2
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
2
3
 
3
4
  module.exports = async function deleteAccount(accountId, username) {
4
5
  try {
@@ -1,5 +1,6 @@
1
- const Account = require('../../models/Account');
2
- const Transaction = require('../../models/Transaction');
1
+ const path = require("path")
2
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
3
+ const Transaction = require(path.join(__dirname, '..', '..', 'models', 'Transaction'));
3
4
  module.exports = async function getAccountLogs(username) {
4
5
  try {
5
6
  const myAccounts = await Account.findAll({
@@ -1,5 +1,6 @@
1
- const Account = require('../../models/Account');
2
- const Transaction = require('../../models/Transaction');
1
+ const path = require("path");
2
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
3
+ const Transaction = require(path.join(__dirname, '..', '../models', 'Transaction'));
3
4
  module.exports = async function removeManny(accountId, amount) {
4
5
  try {
5
6
  const acc = await Account.findByPk(accountId);
@@ -1,9 +1,10 @@
1
+ const path = require("path");
1
2
  const bcrypt = require('bcrypt');
2
- const Account = require('../../models/Account');
3
- const User = require('../../models/User');
4
- const Transaction = require('../../models/Transaction');
5
- const sequelize = require('../../config/init-db');
6
- const { sendBotNotification } = require('../bot/bot');
3
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
4
+ const User = require(path.join(__dirname, '..', '..', 'models', 'User'));
5
+ const Transaction = require(path.join(__dirname, '..', '..', 'models', 'Transaction'));
6
+ const sequelize = require(path.join(__dirname, '..', '..', 'config', 'init-db'));
7
+ const { sendBotNotification } = require(path.join(__dirname, '..', 'bot', 'bot'));
7
8
  const logger = require("custom-color-logs").print;
8
9
  module.exports = async function transferManny(fromId, toId, amount, pinCode, totpCode = null) {
9
10
  const t = await sequelize.transaction();
@@ -1,10 +1,11 @@
1
1
  const cron = require('node-cron');
2
2
  const nodemailer = require('nodemailer');
3
- const { Op } = require('sequelize'); // Явный импорт операторов Sequelize
4
- const Account = require('../../models/Account');
5
- const Credit = require('../../models/Credit');
6
- const User = require('../../models/User');
7
- const sequelize = require('../../config/init-db');
3
+ const { Op } = require('sequelize');
4
+ const path = require("path");
5
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
6
+ const Credit = require(path.join(__dirname, '..', '..', 'models', 'Credit'));
7
+ const User = require(path.join(__dirname, '..', '..', 'models', 'User'));
8
+ const sequelize = require(path.join(__dirname, '..', '..', 'config', 'init-db'));
8
9
  const logger = require("custom-color-logs").print;
9
10
  const transporter = nodemailer.createTransport({
10
11
  service: 'gmail',
@@ -0,0 +1 @@
1
+ <h3 style='color:red;'>🚫 Заморозка счета</h3><p>Ваш банковский счет #{accountId} заблокирован администрацией.</p>
@@ -0,0 +1 @@
1
+ 🚫 Счет #{accountId} ЗАБЛОКИРОВАН администратором.
@@ -0,0 +1 @@
1
+ <h3>⚠️ Снижение уровня защиты</h3><p>2FA-статус аккаунта {name} был отключен.</p>
@@ -0,0 +1 @@
1
+ ⚠️ Защита 2FA ОТКЛЮЧЕНА для аккаунта {name}.
@@ -0,0 +1 @@
1
+ <h3>🔒 Защита профиля</h3><p>2FA-статус аккаунта {name} успешно активирован.</p>
@@ -0,0 +1 @@
1
+ 🔒 Защита 2FA успешно ВКЛЮЧЕНА для аккаунта {name}.
@@ -0,0 +1 @@
1
+ <h3>🔔 Уведомление безопасности</h3><p>Успешный вход в личный кабинет: <b>{name}</b></p>
@@ -0,0 +1 @@
1
+ 🔔 Вход в систему: Профиль {name} успешно авторизован.
@@ -0,0 +1 @@
1
+ <h2>Здравствуйте, {surname} {realName}!</h2><p>На ваш счёт зарегистрировали аккаунт в банке City-bank.</p><p>{twoFaBlock}</p><p>Если забыли пароль используйте токен - <b>[{token}]</b></p><p>Ваш пароль - <b>[{password}]</b></p><br><p>С уважением, система банка City-bank ©</p>
@@ -0,0 +1,7 @@
1
+ Здравствуйте, {surname} {realName}!
2
+ На ваш ник {name} зарегистрирован аккаунт в City-bank.
3
+ {twoFaBlock}
4
+ Если забыли пароль используйте токен - [{token}]
5
+ Ваш пароль - [{password}]
6
+
7
+ С уважением, система банка City-bank ©
@@ -0,0 +1 @@
1
+ <h3>💸 Списание со счета</h3><p>Вы перевели <b>{amount} руб.</b> на счет #{toId}</p>
@@ -0,0 +1 @@
1
+ 💸 Списание со счета #{fromId}: {amount} руб. отправлено на счет #{toId}.
@@ -0,0 +1 @@
1
+ <h3>💰 Входящий перевод</h3><p>На ваш счет зачислено <b>{amount} руб.</b> от счета #{fromId}</p>
@@ -0,0 +1 @@
1
+ 💰 Зачисление на счет #{toId}: Получено {amount} руб. со счета #{fromId}.
@@ -0,0 +1 @@
1
+ <h3 style='color:green;'>✅ Разблокировка счета</h3><p>Ваш банковский счет #{accountId} успешно активирован.</p>
@@ -0,0 +1 @@
1
+ ✅ Счет #{accountId} РАЗБЛОКИРОВАН администратором.
@@ -1,5 +1,6 @@
1
1
  const bcrypt = require('bcrypt');
2
- const User = require('../../models/User');
2
+ const path = require("path");
3
+ const User = require(path.join(__dirname, '..', '..', 'models', 'User'));
3
4
  module.exports = async function changePassword(name, oldPassword, newPassword, totp = null) {
4
5
  try {
5
6
  const user = await User.findByPk(name);
@@ -1,6 +1,7 @@
1
1
  const bcrypt = require('bcrypt');
2
2
  const crypto = require('crypto');
3
- const User = require('../../models/User');
3
+ const path = require("path");
4
+ const User = require(path.join(__dirname, '..', '..', 'models', 'User'));
4
5
  const nodemailer = require('nodemailer');
5
6
  const { sendBotNotification } = require('../bot/bot');
6
7
  module.exports = async function createUser(data) {
@@ -1,5 +1,6 @@
1
1
  const bcrypt = require('bcrypt');
2
- const User = require('../../models/User');
2
+ const path = require("path");
3
+ const User = require(path.join(__dirname, '..', '..', 'models', 'User'));
3
4
  module.exports = async function deleteUser(name, password, totp = null) {
4
5
  try {
5
6
  const user = await User.findByPk(name);
@@ -1,5 +1,6 @@
1
- const User = require('../../models/User');
2
- const { sendBotNotification } = require('../bot/bot');
1
+ const path = require("path");
2
+ const User = require(path.join(__dirname, '..', '..', 'models', 'User'));
3
+ const { sendBotNotification } = require(path.join(__dirname, '..', 'bot', 'bot'));
3
4
  module.exports = async function disable2FA(name) {
4
5
  try {
5
6
  const user = await User.findByPk(name);
@@ -1,7 +1,8 @@
1
1
  const crypto = require('crypto');
2
2
  const bcrypt = require('bcrypt');
3
- const User = require('../../models/User');
4
- const { sendBotNotification } = require('../bot/bot');
3
+ const path = require("path");
4
+ const User = require(path.join(__dirname, '..', '..', 'models', 'User'));
5
+ const { sendBotNotification } = require(path.join(__dirname, '..', 'bot', 'bot'));
5
6
  module.exports = async function enable2FA(name) {
6
7
  try {
7
8
  const user = await User.findByPk(name);
@@ -1,6 +1,7 @@
1
1
  const bcrypt = require('bcrypt');
2
- const User = require('../../models/User');
3
- const { sendBotNotification } = require('../bot/bot');
2
+ const path = require("path");
3
+ const User = require(path.join(__dirname, '..', '..', 'models', 'User'));
4
+ const { sendBotNotification } = require(path.join(__dirname, '..', 'bot', 'bot'));
4
5
  const logger = require("custom-color-logs").print;
5
6
  module.exports = async function loginUser(name, password, totpCode = null) {
6
7
  try {
@@ -1,4 +1,5 @@
1
- const Account = require('../../models/Account');
1
+ const path = require("path");
2
+ const Account = require(path.join(__dirname, '..', '..', 'models', 'Account'));
2
3
  module.exports = async function mathManny(username) {
3
4
  try {
4
5
  const total = await Account.sum('manny', { where: { user: username } });
package/index.js CHANGED
@@ -1,20 +1,21 @@
1
1
  const logger = require("custom-color-logs").print;
2
2
  console.log(logger.ServerBankInfo("Модуль банка запущен!"))
3
3
  require('dotenv').config();
4
+ const path = require("path")
4
5
  const express = require('express');
5
6
  const cookieParser = require('cookie-parser');
6
7
  const bcrypt = require('bcrypt');
7
- const sequelize = require('./database/config/init-db');
8
+ const sequelize = require(path.join(__dirname, 'database', 'config', 'init-db'));
8
9
  const User = require('./database/models/User');
9
- const { writeTemplatesIfNotExist } = require('./database/services/bot/write');
10
- const registerRoutes = require('./server/server');
11
- const Transaction = require('./database/models/Transaction');
10
+ const { writeTemplatesIfNotExist } = require(path.join(__dirname, 'database', 'services', 'bot', 'write'));
11
+ const registerRoutes = require(path.join(__dirname, 'server', 'server'));
12
+ const Transaction = require(path.join(__dirname, 'database', 'models', 'Transaction'));
12
13
  const app = express();
13
- const path = require("path")
14
- const { verifySession } = require('./server/server');
14
+
15
+ const { verifySession } = require(path.join(__dirname, 'server', 'server'));
15
16
  app.use(express.json());
16
17
  app.use(cookieParser());
17
- require('./database/services/bot/cron-schedule');
18
+ require(path.join(__dirname, 'database', 'services', 'bot', 'cron-schedule'));
18
19
  async function Bank() {
19
20
  try {
20
21
  await sequelize.sync();
@@ -37,10 +38,10 @@ async function Bank() {
37
38
  });
38
39
  console.log(logger.ServerBankInfo(`Супер пользвотель создан`))
39
40
  const configuredApp = registerRoutes(app);
40
- app.use('/css', express.static(path.join(__dirname, 'public/css')));
41
- app.use('/js', express.static(path.join(__dirname, 'public/js')));
42
- app.use('/uploads', express.static(path.join(__dirname, 'public/uploads')));
43
- const { verifyPageSession } = require('./server/middleware/auth');
41
+ app.use('/css', express.static(path.join(__dirname, 'public', 'css')));
42
+ app.use('/js', express.static(path.join(__dirname, 'public', 'js')));
43
+ app.use('/uploads', express.static(path.join(__dirname, 'public', 'uploads')));
44
+ const { verifyPageSession } = require(path.join(__dirname, 'server', 'middleware', 'auth'));
44
45
  const pages = ['general.html', 'profile.html', 'accounts.html', 'transfer.html', 'history.html', 'credit.html', 'admin.html'];
45
46
  pages.forEach(page => {
46
47
  app.get(`/${page}`, verifyPageSession, (req, res) => {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "sequelize-game-bank",
3
- "version": "1.0.1",
3
+ "version": "1.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",
7
7
  "scripts": {
8
8
  "start": "node test.js",
9
- "ship":"npm publish"
9
+ "ship": "npm publish"
10
10
  },
11
11
  "dependencies": {
12
12
  "bcrypt": "^6.0.0",
package/server/server.js CHANGED
@@ -1,9 +1,9 @@
1
+ const path = require('path');
1
2
  const jwt = require('jsonwebtoken');
2
3
  const bcrypt = require('bcrypt');
3
- const User = require('../database/models/User');
4
- const Account = require('../database/models/Account');
4
+ const User = require(path.join(__dirname, '..', 'database', 'models', 'User'));
5
+ const Account = require(path.join(__dirname, '..', 'database', 'models', 'Account'));
5
6
  const multer = require('multer');
6
- const path = require('path');
7
7
  const fs = require('fs');
8
8
  const logger = require("custom-color-logs").print;
9
9
  const storage = multer.diskStorage({
@@ -27,8 +27,8 @@ const upload = multer({
27
27
  },
28
28
  limits: { fileSize: 2 * 1024 * 1024 }
29
29
  });
30
- const usersHub = require('../database/services/users');
31
- const accountsHub = require('../database/services/accounts');
30
+ const usersHub = require(path.join(__dirname, '..', 'database', 'services', 'users'));
31
+ const accountsHub = require(path.join(__dirname, '..', 'database', 'services', 'accounts'));
32
32
 
33
33
  function verifySession(req, res, next) {
34
34
  const token = req.cookies.token;