zyket 1.0.55 → 1.1.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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "enabledPlugins": {}
3
+ }
package/index.js CHANGED
@@ -13,6 +13,7 @@ const InteractiveStorageExtension = require("./src/extensions/interactive-storag
13
13
  const AuthService = require("./src/services/auth");
14
14
  const MulterMiddleware = require("./src/extensions/interactive-storage/middlewares/MulterMiddleware");
15
15
  const RedirectResponse = require("./src/services/express/RedirectResponse");
16
+ const ViteService = require("./src/services/vite");
16
17
 
17
18
 
18
19
  module.exports = {
@@ -27,5 +28,6 @@ module.exports = {
27
28
  Extension,
28
29
  AuthService,
29
30
  MulterMiddleware,
30
- RedirectResponse
31
+ RedirectResponse,
32
+ ViteService,
31
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zyket",
3
- "version": "1.0.55",
3
+ "version": "1.1.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -13,26 +13,31 @@
13
13
  "license": "ISC",
14
14
  "description": "",
15
15
  "dependencies": {
16
- "@bull-board/express": "^6.14.2",
17
- "better-auth": "^1.4.18",
18
- "bullmq": "^5.63.0",
16
+ "@bull-board/express": "^6.20.6",
17
+ "@tailwindcss/vite": "^4.2.2",
18
+ "@vitejs/plugin-react": "^6.0.1",
19
+ "better-auth": "^1.5.6",
20
+ "bullmq": "^5.71.0",
19
21
  "colors": "^1.4.0",
20
- "cors": "^2.8.5",
21
- "dotenv": "^17.2.3",
22
- "express": "^5.1.0",
22
+ "cors": "^2.8.6",
23
+ "dotenv": "^17.3.1",
24
+ "express": "^5.2.1",
23
25
  "fast-glob": "^3.3.3",
24
- "mariadb": "^3.4.5",
25
- "minio": "^8.0.6",
26
- "multer": "^2.0.2",
26
+ "mariadb": "^3.5.2",
27
+ "minio": "^8.0.7",
28
+ "multer": "^2.1.1",
27
29
  "node-cron": "^4.2.1",
28
- "node-dependency-injection": "^3.2.4",
29
- "pg": "^8.18.0",
30
+ "node-dependency-injection": "^3.2.6",
31
+ "pg": "^8.20.0",
30
32
  "prompts": "^2.4.2",
31
- "redis": "^5.9.0",
32
- "sequelize": "^6.37.7",
33
- "socket.io": "^4.8.1",
33
+ "redis": "^5.11.0",
34
+ "sequelize": "^6.37.8",
35
+ "socket.io": "^4.8.3",
36
+ "sqlite3": "^6.0.1",
34
37
  "swagger-jsdoc": "^6.2.8",
35
38
  "swagger-ui-express": "^5.0.1",
36
- "umzug": "^3.8.2"
39
+ "tailwindcss": "^4.2.2",
40
+ "umzug": "^3.8.2",
41
+ "vite": "^8.0.1"
37
42
  }
38
43
  }
@@ -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
 
@@ -14,6 +14,7 @@ const s3Activated = process.env.S3_ENDPOINT && process.env.S3_ACCESS_KEY && proc
14
14
  const schedulerActivated = process.env.DISABLE_SCHEDULER !== 'true';
15
15
  const socketActivated = process.env.DISABLE_SOCKET !== 'true';
16
16
  const expressActivated = process.env.DISABLE_EXPRESS !== 'true';
17
+ const viteActivated = process.env.VITE_ROOT && process.env.DISABLE_VITE !== 'true';
17
18
 
18
19
  module.exports = [
19
20
  ["logger", require("./logger"), ["@service_container", process.env.LOG_DIRECTORY || `${process.cwd()}/logs`, process.env.DEBUG === "true"]],
@@ -25,5 +26,6 @@ module.exports = [
25
26
  schedulerActivated ? ["scheduler", Scheduler, ["@service_container"]] : null,
26
27
  bullmqActivated ? ["bullmq", require("./bullmq"), ["@service_container"]] : null,
27
28
  socketActivated ? ["socketio", SocketIO, ["@service_container"]] : null,
28
- expressActivated ? ["express", Express, ["@service_container"]] : null
29
+ expressActivated ? ["express", Express, ["@service_container"]] : null,
30
+ viteActivated ? ["vite", require("./vite"), ["@service_container", process.env.VITE_ROOT, Number(process.env.VITE_PORT) || 5173]] : null,
29
31
  ].filter(Boolean);
@@ -11,13 +11,14 @@ module.exports = class TemplateManager extends Service {
11
11
  }
12
12
 
13
13
  async boot() {
14
- const zyketTemplates = await fg(['**/*.js'], {
14
+ const zyketTemplates = await fg(['**/*'], {
15
15
  cwd: path.join(__dirname, '../../templates'),
16
16
  });
17
+ console.log('Found templates:', zyketTemplates);
17
18
  for (const template of zyketTemplates) {
18
19
  const templatePath = path.join(__dirname, '../../templates', template);
19
20
  const templateContent = fs.readFileSync(templatePath, 'utf-8');
20
- this.templates[template.replace('.js', '')] = {
21
+ this.templates[template.replace('.jsx', '').replace('.js', '').replace('.html', '').replace('.css', '')] = {
21
22
  route: template,
22
23
  content: templateContent
23
24
  };
@@ -0,0 +1,76 @@
1
+ const Service = require("../Service");
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+
5
+ module.exports = class Vite extends Service {
6
+ #container;
7
+ #viteServer;
8
+ #root;
9
+ #port;
10
+
11
+ constructor(container, root, port) {
12
+ super("vite");
13
+ this.#container = container;
14
+ this.#root = path.resolve(process.cwd(), root || process.cwd());
15
+ this.#port = port || 5173;
16
+ }
17
+
18
+ async boot() {
19
+ await this.#loadViteFolder();
20
+ const { createServer } = await import("vite");
21
+
22
+ const configFile = this.#resolveConfigFile();
23
+
24
+ this.#viteServer = await createServer({
25
+ root: this.#root,
26
+ configFile,
27
+ server: {
28
+ port: this.#port,
29
+ strictPort: false,
30
+ },
31
+ });
32
+
33
+ await this.#viteServer.listen();
34
+
35
+ const resolvedPort = this.#viteServer.httpServer?.address()?.port ?? this.#port;
36
+ this.#container.get("logger").info(
37
+ `Vite dev server running on http://localhost:${resolvedPort} (root: ${this.#viteServer.config.root})`
38
+ );
39
+ }
40
+
41
+ #resolveConfigFile() {
42
+ const candidates = ["vite.config.js", "vite.config.ts", "vite.config.mjs"];
43
+ for (const candidate of candidates) {
44
+ const fullPath = path.join(this.#root, candidate);
45
+ if (fs.existsSync(fullPath)) return fullPath;
46
+ }
47
+ return false;
48
+ }
49
+
50
+ async #loadViteFolder() {
51
+ // exists folder named procces.env.VITE_ROOT in root of project, if not create it and add index.html and main.jsx
52
+ const viteRoot = path.join(process.cwd(), process.env.VITE_ROOT || "frontend");
53
+
54
+ if (!fs.existsSync(viteRoot)) fs.mkdirSync(viteRoot, { recursive: true });
55
+
56
+ if (!fs.existsSync(path.join(viteRoot, "index.html"))) {
57
+ this.#container.get('template-manager').installFile('default/frontend/index', path.join(process.cwd(), process.env.VITE_ROOT || "frontend", "index.html"));
58
+ }
59
+
60
+ if (!fs.existsSync(path.join(viteRoot, "main.jsx"))) {
61
+ this.#container.get('template-manager').installFile('default/frontend/main', path.join(process.cwd(), process.env.VITE_ROOT || "frontend", "main.jsx"));
62
+ }
63
+
64
+ if (!fs.existsSync(path.join(viteRoot, "vite.config.js"))) {
65
+ this.#container.get('template-manager').installFile('default/frontend/vite.config', path.join(process.cwd(), process.env.VITE_ROOT || "frontend", "vite.config.js"));
66
+ }
67
+
68
+ if (!fs.existsSync(path.join(viteRoot, "styles.css"))) {
69
+ this.#container.get('template-manager').installFile('default/frontend/styles', path.join(process.cwd(), process.env.VITE_ROOT || "frontend", "styles.css"));
70
+ }
71
+ }
72
+
73
+ server() {
74
+ return this.#viteServer;
75
+ }
76
+ };
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Test Website</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="./main.jsx"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,6 @@
1
+ import { createRoot } from 'react-dom/client'
2
+ import './styles.css'
3
+
4
+ createRoot(document.getElementById('root')).render(<div>
5
+ <p className='underline text-red-500 text-3xl m-4'>Test</p>
6
+ </div>)
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import tailwindcss from '@tailwindcss/vite'
4
+
5
+ // https://vite.dev/config/
6
+ export default defineConfig({
7
+ plugins: [
8
+ react(),
9
+ tailwindcss()
10
+ ],
11
+ })
@@ -15,7 +15,7 @@ module.exports = class EnvManager {
15
15
  const envsToCreate = {
16
16
  DEBUG: true,
17
17
  PORT: 3000,
18
- DISABLE_SOCKET: false,
18
+ DISABLE_SOCKET: true,
19
19
  DISABLE_EXPRESS: false,
20
20
  DISABLE_EVENTS: true,
21
21
  DISABLE_BULLMQ: true,
@@ -30,6 +30,9 @@ module.exports = class EnvManager {
30
30
  S3_SECRET_KEY: '',
31
31
  LOG_DIRECTORY: "./logs",
32
32
  QUEUES: '',
33
+ VITE_ROOT: './frontend',
34
+ VITE_PORT: 5173,
35
+ DISABLE_VITE: true,
33
36
  }
34
37
 
35
38
  return Object.entries(envsToCreate).reduce((acc, [key, value]) => {