@seip/bluebird-js 0.0.1 → 0.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.
Files changed (81) hide show
  1. package/.env_example +53 -53
  2. package/AGENTS.md +426 -403
  3. package/LICENSE +1 -1
  4. package/README.md +292 -285
  5. package/app/routes/api.js +50 -50
  6. package/app/routes/web.js +55 -53
  7. package/app/views/about.js +63 -0
  8. package/app/views/dashboard.js +147 -0
  9. package/app/views/index.js +80 -0
  10. package/app/views/layouts/main/view.js +81 -0
  11. package/app/views/legal/terms.html +19 -0
  12. package/app/views/login.js +80 -0
  13. package/core/app.d.ts +18 -18
  14. package/core/app.js +684 -644
  15. package/core/auth.d.ts +13 -13
  16. package/core/auth.js +326 -326
  17. package/core/cache.d.ts +17 -17
  18. package/core/cache.js +475 -475
  19. package/core/cli/doctor.js +287 -287
  20. package/core/cli/ecosystem.js +162 -162
  21. package/core/cli/init.js +779 -779
  22. package/core/cli/migrate.js +541 -541
  23. package/core/cli/model.js +66 -66
  24. package/core/cli/nginx.js +199 -199
  25. package/core/cli/route.js +120 -120
  26. package/core/cli/view.js +55 -36
  27. package/core/config.d.ts +3 -3
  28. package/core/config.js +111 -111
  29. package/core/csrf.d.ts +3 -3
  30. package/core/csrf.js +114 -114
  31. package/core/database.d.ts +15 -15
  32. package/core/database.js +636 -636
  33. package/core/debug.d.ts +3 -3
  34. package/core/debug.js +249 -249
  35. package/core/hash.d.ts +3 -3
  36. package/core/hash.js +194 -194
  37. package/core/html.d.ts +42 -0
  38. package/core/html.js +217 -0
  39. package/core/index.d.ts +1176 -1071
  40. package/core/logger.d.ts +3 -3
  41. package/core/logger.js +127 -124
  42. package/core/middleware.d.ts +3 -3
  43. package/core/middleware.js +28 -28
  44. package/core/model.d.ts +19 -19
  45. package/core/model.js +600 -600
  46. package/core/queue.d.ts +13 -13
  47. package/core/queue.js +172 -172
  48. package/core/ratelimit.d.ts +3 -3
  49. package/core/ratelimit.js +145 -145
  50. package/core/redis.d.ts +21 -21
  51. package/core/redis.js +230 -230
  52. package/core/render-cache.js +212 -0
  53. package/core/render.d.ts +3 -3
  54. package/core/render.js +199 -555
  55. package/core/router.d.ts +3 -3
  56. package/core/router.js +171 -171
  57. package/core/seo.d.ts +3 -3
  58. package/core/seo.js +106 -106
  59. package/core/swagger.d.ts +3 -3
  60. package/core/swagger.js +60 -60
  61. package/core/upload.d.ts +13 -13
  62. package/core/upload.js +102 -102
  63. package/core/util/colors.js +82 -82
  64. package/core/validate.d.ts +15 -15
  65. package/core/validate.js +364 -364
  66. package/core/view-loader.js +162 -0
  67. package/core/vite.d.ts +3 -3
  68. package/core/vite.js +145 -145
  69. package/core/ws.d.ts +13 -13
  70. package/core/ws.js +245 -245
  71. package/index.js +18 -18
  72. package/jsconfig.json +15 -15
  73. package/package.json +85 -86
  74. package/production.md +273 -273
  75. package/public/css/bluebird.min.css +1 -1
  76. package/public/js/bluebird-client.js +1780 -1662
  77. package/public/js/bluebird.min.js +1072 -1072
  78. package/app/views/about.html +0 -161
  79. package/app/views/dashboard.html +0 -140
  80. package/app/views/index.html +0 -150
  81. package/app/views/login.html +0 -144
package/core/cli/model.js CHANGED
@@ -1,66 +1,66 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import colors from "../util/colors.js";
6
-
7
- /**
8
- * Creates a new Model file in app/models/.
9
- * @param {string} name - Model class name (e.g. User, Product).
10
- */
11
- export function makeModel(name) {
12
- if (!name) {
13
- console.log(colors.red("[ERROR] Missing model name."));
14
- console.log("Usage: npx bluebird-js make:model <Name>");
15
- process.exit(1);
16
- }
17
-
18
- const cleanName = name.charAt(0).toUpperCase() + name.slice(1).replace(/[^a-zA-Z0-9_]/g, "");
19
- const tableName = cleanName.toLowerCase().endsWith("s")
20
- ? cleanName.toLowerCase()
21
- : `${cleanName.toLowerCase()}s`;
22
-
23
- const modelsDir = path.resolve(process.cwd(), "app/models");
24
- if (!fs.existsSync(modelsDir)) {
25
- fs.mkdirSync(modelsDir, { recursive: true });
26
- }
27
-
28
- const filename = `${cleanName.toLowerCase()}.js`;
29
- const filePath = path.join(modelsDir, filename);
30
-
31
- if (fs.existsSync(filePath)) {
32
- console.log(colors.yellow(`[WARN] Model file already exists at app/models/${filename}`));
33
- process.exit(0);
34
- }
35
-
36
- const template = `import Model from "@seip/bluebird-js/core/model.js";
37
-
38
- /**
39
- * ${cleanName} Model representation.
40
- * Provides transparent schema definitions, validation bridge, and query shortcuts.
41
- * Note: For complex multi-tier enterprise ORMs, Prisma is recommended.
42
- */
43
- export default class ${cleanName} extends Model {
44
- static table = "${tableName}";
45
- static primaryKey = "id";
46
- static timestamps = true;
47
- static softDelete = false;
48
-
49
- static schema = {
50
- id: { type: "int", primary: true, auto: true },
51
- name: { type: "string", length: 150, required: true },
52
- created_at: { type: "date" },
53
- updated_at: { type: "date" },
54
- };
55
- }
56
- `;
57
-
58
- fs.writeFileSync(filePath, template, "utf-8");
59
- console.log(colors.green(`[OK] Model created: app/models/${filename}`));
60
- }
61
-
62
- const args = process.argv.slice(2);
63
- if (args[0] === "make:model" || args[0] === "model") {
64
- const modelName = args.find((a, i) => i > 0 && !a.startsWith("-"));
65
- makeModel(modelName);
66
- }
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import colors from "../util/colors.js";
6
+
7
+ /**
8
+ * Creates a new Model file in app/models/.
9
+ * @param {string} name - Model class name (e.g. User, Product).
10
+ */
11
+ export function makeModel(name) {
12
+ if (!name) {
13
+ console.log(colors.red("[ERROR] Missing model name."));
14
+ console.log("Usage: npx bluebird-js make:model <Name>");
15
+ process.exit(1);
16
+ }
17
+
18
+ const cleanName = name.charAt(0).toUpperCase() + name.slice(1).replace(/[^a-zA-Z0-9_]/g, "");
19
+ const tableName = cleanName.toLowerCase().endsWith("s")
20
+ ? cleanName.toLowerCase()
21
+ : `${cleanName.toLowerCase()}s`;
22
+
23
+ const modelsDir = path.resolve(process.cwd(), "app/models");
24
+ if (!fs.existsSync(modelsDir)) {
25
+ fs.mkdirSync(modelsDir, { recursive: true });
26
+ }
27
+
28
+ const filename = `${cleanName.toLowerCase()}.js`;
29
+ const filePath = path.join(modelsDir, filename);
30
+
31
+ if (fs.existsSync(filePath)) {
32
+ console.log(colors.yellow(`[WARN] Model file already exists at app/models/${filename}`));
33
+ process.exit(0);
34
+ }
35
+
36
+ const template = `import Model from "@seip/bluebird-js/core/model.js";
37
+
38
+ /**
39
+ * ${cleanName} Model representation.
40
+ * Provides transparent schema definitions, validation bridge, and query shortcuts.
41
+ * Note: For complex multi-tier enterprise ORMs, Prisma is recommended.
42
+ */
43
+ export default class ${cleanName} extends Model {
44
+ static table = "${tableName}";
45
+ static primaryKey = "id";
46
+ static timestamps = true;
47
+ static softDelete = false;
48
+
49
+ static schema = {
50
+ id: { type: "int", primary: true, auto: true },
51
+ name: { type: "string", length: 150, required: true },
52
+ created_at: { type: "date" },
53
+ updated_at: { type: "date" },
54
+ };
55
+ }
56
+ `;
57
+
58
+ fs.writeFileSync(filePath, template, "utf-8");
59
+ console.log(colors.green(`[OK] Model created: app/models/${filename}`));
60
+ }
61
+
62
+ const args = process.argv.slice(2);
63
+ if (args[0] === "make:model" || args[0] === "model") {
64
+ const modelName = args.find((a, i) => i > 0 && !a.startsWith("-"));
65
+ makeModel(modelName);
66
+ }
package/core/cli/nginx.js CHANGED
@@ -1,199 +1,199 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import colors from "../util/colors.js";
6
-
7
- /**
8
- * Parses .env file to extract APP_URL and PORT.
9
- * @returns {{ domain: string, port: number, appUrl: string }}
10
- */
11
- function getEnvConfig() {
12
- const env = { ...process.env };
13
- const envPath = path.resolve(process.cwd(), ".env");
14
- if (fs.existsSync(envPath)) {
15
- const content = fs.readFileSync(envPath, "utf-8");
16
- content.split(/\r?\n/).forEach((line) => {
17
- line = line.trim();
18
- if (line && !line.startsWith("#") && line.includes("=")) {
19
- const idx = line.indexOf("=");
20
- const key = line.substring(0, idx).trim();
21
- const value = line.substring(idx + 1).trim().replace(/^['"]|['"]$/g, "");
22
- env[key] = value;
23
- }
24
- });
25
- }
26
-
27
- let domain = "";
28
- if (env.APP_URL) {
29
- try {
30
- const parsedUrl = new URL(env.APP_URL.includes("://") ? env.APP_URL : `http://${env.APP_URL}`);
31
- domain = parsedUrl.hostname;
32
- } catch {
33
- domain = env.APP_URL.replace(/^https?:\/\//, "").replace(/\/.*$/, "").replace(/:\d+$/, "").trim();
34
- }
35
- }
36
-
37
- const port = parseInt(env.PORT || "3000", 10);
38
- return { domain, port, appUrl: env.APP_URL || "" };
39
- }
40
-
41
- /**
42
- * Generates Host Nginx reverse proxy configuration snippet with upstream keepalive,
43
- * direct public/ static asset delivery via try_files, and 5M body limit.
44
- */
45
- function generateNginxConfig() {
46
- const rawArgs = process.argv.slice(2);
47
- const filteredArgs = rawArgs.filter(
48
- (a) => a !== "nginx:conf" && a !== "nginx:host" && a !== "nginx" && !a.endsWith("nginx.js") && !a.endsWith("init.js")
49
- );
50
-
51
- const envConfig = getEnvConfig();
52
-
53
- let domainArg = null;
54
- let portArg = null;
55
- let rootPathArg = null;
56
-
57
- for (let i = 0; i < filteredArgs.length; i++) {
58
- const arg = filteredArgs[i];
59
- if (arg === "--root" && filteredArgs[i + 1]) {
60
- rootPathArg = filteredArgs[++i];
61
- } else if (arg.startsWith("--root=")) {
62
- rootPathArg = arg.split("=")[1];
63
- } else if (!isNaN(Number(arg))) {
64
- portArg = arg;
65
- } else if (arg.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(arg)) {
66
- rootPathArg = arg;
67
- } else if (!arg.startsWith("-") && !domainArg) {
68
- domainArg = arg;
69
- } else if (!arg.startsWith("-") && !rootPathArg) {
70
- rootPathArg = arg;
71
- }
72
- }
73
-
74
- let domain = domainArg || envConfig.domain;
75
- let port = portArg ? parseInt(portArg, 10) : envConfig.port;
76
- const projectRoot = (rootPathArg || process.cwd()).replace(/\\/g, "/").replace(/\/$/, "");
77
- const publicRoot = `${projectRoot}/public`;
78
-
79
- if (!domain) {
80
- domain = "example.com";
81
- console.log(colors.yellow("[INFO] No domain provided and APP_URL is not configured in .env. Defaulting to 'example.com'."));
82
- } else if (!domainArg && envConfig.domain) {
83
- console.log(colors.cyan(`[INFO] Using domain '${domain}', port ${port}, and root '${projectRoot}'.`));
84
- console.log(colors.gray(` (Override via: npx bluebird-js nginx:conf <domain> [port] [/var/www/project])\n`));
85
- }
86
-
87
- domain = domain.replace(/^https?:\/\//, "").replace(/\/.*$/, "").replace(/:\d+$/, "").trim();
88
- const upstreamName = `bluebird_${domain.replace(/[^a-zA-Z0-9_]/g, "_")}`;
89
-
90
- const nginxSnippet = `# =============================================================
91
- # Bluebird Host Nginx Reverse Proxy Configuration
92
- # File: /etc/nginx/sites-available/${domain}
93
- # =============================================================
94
-
95
- map $http_upgrade $connection_upgrade {
96
- default upgrade;
97
- '' "";
98
- }
99
-
100
- upstream ${upstreamName} {
101
- server 127.0.0.1:${port};
102
- keepalive 64;
103
- }
104
-
105
- server {
106
- listen 80;
107
- listen [::]:80;
108
- server_name ${domain};
109
-
110
- # Public static directory served directly by Nginx
111
- root ${publicRoot};
112
-
113
- # Maximum request body size for file uploads (5MB)
114
- client_max_body_size 5M;
115
-
116
- # Gzip compression for text/assets
117
- gzip on;
118
- gzip_vary on;
119
- gzip_min_length 1024;
120
- gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml;
121
-
122
- # Security: Block hidden files (.env, .git, etc.)
123
- location ~* /\\.(env|git|svn|htaccess) {
124
- deny all;
125
- return 404;
126
- }
127
-
128
- # Vite compiled production bundles (immutable long-term cache)
129
- location /dist/ {
130
- try_files $uri =404;
131
- expires 365d;
132
- add_header Cache-Control "public, max-age=31536000, immutable";
133
- access_log off;
134
- }
135
-
136
- # Static assets in public/ (CSS, JS, images, fonts, media)
137
- location ~* \\.(?:css|js|mjs|jpg|jpeg|gif|png|ico|svg|webp|avif|woff|woff2|ttf|eot|mp4|webm|mp3)$ {
138
- try_files $uri =404;
139
- expires 30d;
140
- add_header Cache-Control "public, max-age=2592000, immutable";
141
- access_log off;
142
- }
143
-
144
- # Serve static files from public/ if they exist, otherwise proxy to Bluebird
145
- location / {
146
- try_files $uri @bluebird;
147
- }
148
-
149
- # Reverse proxy to Bluebird Node.js upstream with persistent keepalive connections
150
- location @bluebird {
151
- proxy_pass http://${upstreamName};
152
- proxy_http_version 1.1;
153
-
154
- # Persistent keepalive & WebSocket upgrade support
155
- proxy_set_header Upgrade $http_upgrade;
156
- proxy_set_header Connection $connection_upgrade;
157
-
158
- # Standard proxy headers
159
- proxy_set_header Host $host;
160
- proxy_set_header X-Real-IP $remote_addr;
161
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
162
- proxy_set_header X-Forwarded-Proto $scheme;
163
- proxy_set_header X-Forwarded-Host $host;
164
- proxy_set_header X-Forwarded-Port $server_port;
165
-
166
- # Proxy timeouts
167
- proxy_connect_timeout 60s;
168
- proxy_send_timeout 60s;
169
- proxy_read_timeout 60s;
170
- }
171
- }`;
172
-
173
- console.log(colors.bold.cyan("============================================================="));
174
- console.log(colors.bold.cyan(` Host Nginx Configuration & Let's Encrypt Setup for: ${domain}`));
175
- console.log(colors.bold.cyan("============================================================="));
176
- console.log("");
177
- console.log(colors.yellow("1. Create the site configuration file on your VPS:"));
178
- console.log(colors.green(` sudo nano /etc/nginx/sites-available/${domain}`));
179
- console.log("");
180
- console.log(colors.yellow("2. Paste the following configuration block:"));
181
- console.log("");
182
- console.log(colors.white(nginxSnippet));
183
- console.log("");
184
- console.log(colors.yellow("3. Enable the site configuration:"));
185
- console.log(colors.green(` sudo ln -s /etc/nginx/sites-available/${domain} /etc/nginx/sites-enabled/`));
186
- console.log("");
187
- console.log(colors.yellow("4. Test Nginx syntax:"));
188
- console.log(colors.green(" sudo nginx -t"));
189
- console.log("");
190
- console.log(colors.yellow("5. Reload Nginx to apply changes:"));
191
- console.log(colors.green(" sudo systemctl reload nginx"));
192
- console.log("");
193
- console.log(colors.yellow("6. Provision free SSL certificate with Certbot (Let's Encrypt):"));
194
- console.log(colors.green(` sudo certbot --nginx -d ${domain}`));
195
- console.log("");
196
- console.log(colors.bold.cyan("============================================================="));
197
- }
198
-
199
- generateNginxConfig();
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import colors from "../util/colors.js";
6
+
7
+ /**
8
+ * Parses .env file to extract APP_URL and PORT.
9
+ * @returns {{ domain: string, port: number, appUrl: string }}
10
+ */
11
+ function getEnvConfig() {
12
+ const env = { ...process.env };
13
+ const envPath = path.resolve(process.cwd(), ".env");
14
+ if (fs.existsSync(envPath)) {
15
+ const content = fs.readFileSync(envPath, "utf-8");
16
+ content.split(/\r?\n/).forEach((line) => {
17
+ line = line.trim();
18
+ if (line && !line.startsWith("#") && line.includes("=")) {
19
+ const idx = line.indexOf("=");
20
+ const key = line.substring(0, idx).trim();
21
+ const value = line.substring(idx + 1).trim().replace(/^['"]|['"]$/g, "");
22
+ env[key] = value;
23
+ }
24
+ });
25
+ }
26
+
27
+ let domain = "";
28
+ if (env.APP_URL) {
29
+ try {
30
+ const parsedUrl = new URL(env.APP_URL.includes("://") ? env.APP_URL : `http://${env.APP_URL}`);
31
+ domain = parsedUrl.hostname;
32
+ } catch {
33
+ domain = env.APP_URL.replace(/^https?:\/\//, "").replace(/\/.*$/, "").replace(/:\d+$/, "").trim();
34
+ }
35
+ }
36
+
37
+ const port = parseInt(env.PORT || "3000", 10);
38
+ return { domain, port, appUrl: env.APP_URL || "" };
39
+ }
40
+
41
+ /**
42
+ * Generates Host Nginx reverse proxy configuration snippet with upstream keepalive,
43
+ * direct public/ static asset delivery via try_files, and 5M body limit.
44
+ */
45
+ function generateNginxConfig() {
46
+ const rawArgs = process.argv.slice(2);
47
+ const filteredArgs = rawArgs.filter(
48
+ (a) => a !== "nginx:conf" && a !== "nginx:host" && a !== "nginx" && !a.endsWith("nginx.js") && !a.endsWith("init.js")
49
+ );
50
+
51
+ const envConfig = getEnvConfig();
52
+
53
+ let domainArg = null;
54
+ let portArg = null;
55
+ let rootPathArg = null;
56
+
57
+ for (let i = 0; i < filteredArgs.length; i++) {
58
+ const arg = filteredArgs[i];
59
+ if (arg === "--root" && filteredArgs[i + 1]) {
60
+ rootPathArg = filteredArgs[++i];
61
+ } else if (arg.startsWith("--root=")) {
62
+ rootPathArg = arg.split("=")[1];
63
+ } else if (!isNaN(Number(arg))) {
64
+ portArg = arg;
65
+ } else if (arg.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(arg)) {
66
+ rootPathArg = arg;
67
+ } else if (!arg.startsWith("-") && !domainArg) {
68
+ domainArg = arg;
69
+ } else if (!arg.startsWith("-") && !rootPathArg) {
70
+ rootPathArg = arg;
71
+ }
72
+ }
73
+
74
+ let domain = domainArg || envConfig.domain;
75
+ let port = portArg ? parseInt(portArg, 10) : envConfig.port;
76
+ const projectRoot = (rootPathArg || process.cwd()).replace(/\\/g, "/").replace(/\/$/, "");
77
+ const publicRoot = `${projectRoot}/public`;
78
+
79
+ if (!domain) {
80
+ domain = "example.com";
81
+ console.log(colors.yellow("[INFO] No domain provided and APP_URL is not configured in .env. Defaulting to 'example.com'."));
82
+ } else if (!domainArg && envConfig.domain) {
83
+ console.log(colors.cyan(`[INFO] Using domain '${domain}', port ${port}, and root '${projectRoot}'.`));
84
+ console.log(colors.gray(` (Override via: npx bluebird-js nginx:conf <domain> [port] [/var/www/project])\n`));
85
+ }
86
+
87
+ domain = domain.replace(/^https?:\/\//, "").replace(/\/.*$/, "").replace(/:\d+$/, "").trim();
88
+ const upstreamName = `bluebird_${domain.replace(/[^a-zA-Z0-9_]/g, "_")}`;
89
+
90
+ const nginxSnippet = `# =============================================================
91
+ # Bluebird Host Nginx Reverse Proxy Configuration
92
+ # File: /etc/nginx/sites-available/${domain}
93
+ # =============================================================
94
+
95
+ map $http_upgrade $connection_upgrade {
96
+ default upgrade;
97
+ '' "";
98
+ }
99
+
100
+ upstream ${upstreamName} {
101
+ server 127.0.0.1:${port};
102
+ keepalive 64;
103
+ }
104
+
105
+ server {
106
+ listen 80;
107
+ listen [::]:80;
108
+ server_name ${domain};
109
+
110
+ # Public static directory served directly by Nginx
111
+ root ${publicRoot};
112
+
113
+ # Maximum request body size for file uploads (5MB)
114
+ client_max_body_size 5M;
115
+
116
+ # Gzip compression for text/assets
117
+ gzip on;
118
+ gzip_vary on;
119
+ gzip_min_length 1024;
120
+ gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml;
121
+
122
+ # Security: Block hidden files (.env, .git, etc.)
123
+ location ~* /\\.(env|git|svn|htaccess) {
124
+ deny all;
125
+ return 404;
126
+ }
127
+
128
+ # Vite compiled production bundles (immutable long-term cache)
129
+ location /dist/ {
130
+ try_files $uri =404;
131
+ expires 365d;
132
+ add_header Cache-Control "public, max-age=31536000, immutable";
133
+ access_log off;
134
+ }
135
+
136
+ # Static assets in public/ (CSS, JS, images, fonts, media)
137
+ location ~* \\.(?:css|js|mjs|jpg|jpeg|gif|png|ico|svg|webp|avif|woff|woff2|ttf|eot|mp4|webm|mp3)$ {
138
+ try_files $uri =404;
139
+ expires 30d;
140
+ add_header Cache-Control "public, max-age=2592000, immutable";
141
+ access_log off;
142
+ }
143
+
144
+ # Serve static files from public/ if they exist, otherwise proxy to Bluebird
145
+ location / {
146
+ try_files $uri @bluebird;
147
+ }
148
+
149
+ # Reverse proxy to Bluebird Node.js upstream with persistent keepalive connections
150
+ location @bluebird {
151
+ proxy_pass http://${upstreamName};
152
+ proxy_http_version 1.1;
153
+
154
+ # Persistent keepalive & WebSocket upgrade support
155
+ proxy_set_header Upgrade $http_upgrade;
156
+ proxy_set_header Connection $connection_upgrade;
157
+
158
+ # Standard proxy headers
159
+ proxy_set_header Host $host;
160
+ proxy_set_header X-Real-IP $remote_addr;
161
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
162
+ proxy_set_header X-Forwarded-Proto $scheme;
163
+ proxy_set_header X-Forwarded-Host $host;
164
+ proxy_set_header X-Forwarded-Port $server_port;
165
+
166
+ # Proxy timeouts
167
+ proxy_connect_timeout 60s;
168
+ proxy_send_timeout 60s;
169
+ proxy_read_timeout 60s;
170
+ }
171
+ }`;
172
+
173
+ console.log(colors.bold.cyan("============================================================="));
174
+ console.log(colors.bold.cyan(` Host Nginx Configuration & Let's Encrypt Setup for: ${domain}`));
175
+ console.log(colors.bold.cyan("============================================================="));
176
+ console.log("");
177
+ console.log(colors.yellow("1. Create the site configuration file on your VPS:"));
178
+ console.log(colors.green(` sudo nano /etc/nginx/sites-available/${domain}`));
179
+ console.log("");
180
+ console.log(colors.yellow("2. Paste the following configuration block:"));
181
+ console.log("");
182
+ console.log(colors.white(nginxSnippet));
183
+ console.log("");
184
+ console.log(colors.yellow("3. Enable the site configuration:"));
185
+ console.log(colors.green(` sudo ln -s /etc/nginx/sites-available/${domain} /etc/nginx/sites-enabled/`));
186
+ console.log("");
187
+ console.log(colors.yellow("4. Test Nginx syntax:"));
188
+ console.log(colors.green(" sudo nginx -t"));
189
+ console.log("");
190
+ console.log(colors.yellow("5. Reload Nginx to apply changes:"));
191
+ console.log(colors.green(" sudo systemctl reload nginx"));
192
+ console.log("");
193
+ console.log(colors.yellow("6. Provision free SSL certificate with Certbot (Let's Encrypt):"));
194
+ console.log(colors.green(` sudo certbot --nginx -d ${domain}`));
195
+ console.log("");
196
+ console.log(colors.bold.cyan("============================================================="));
197
+ }
198
+
199
+ generateNginxConfig();