@seip/blue-bird 0.7.5 → 0.8.0
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/.env_example +34 -36
- package/AGENTS.md +174 -241
- package/LICENSE +21 -21
- package/README.md +312 -343
- package/{index.js → backend/index.js} +22 -30
- package/backend/routes/api.js +57 -57
- package/core/app.js +338 -402
- package/core/auth.js +262 -256
- package/core/cache.js +174 -174
- package/core/cli/docker.js +488 -370
- package/core/cli/init.js +332 -238
- package/core/cli/route.js +42 -42
- package/core/config.js +52 -52
- package/core/database.js +263 -182
- package/core/debug.js +248 -248
- package/core/logger.js +115 -115
- package/core/middleware.js +27 -27
- package/core/router.js +144 -144
- package/core/swagger.js +40 -40
- package/core/upload.js +77 -77
- package/core/validate.js +380 -380
- package/docker/Dockerfile +16 -16
- package/docker/docker-compose.dev.yml +6 -0
- package/docker/docker-compose.mysql.yml +92 -0
- package/docker/docker-compose.none.yml +68 -0
- package/docker/docker-compose.postgres.yml +93 -0
- package/docker/nginx.conf +98 -106
- package/docker-compose.yml +92 -93
- package/frontend/about.html +98 -0
- package/frontend/css/app.css +0 -0
- package/frontend/favicon.ico +0 -0
- package/frontend/index.html +141 -0
- package/frontend/js/bundle.js +8 -0
- package/package.json +64 -72
- package/backend/logs/2026-07-14/info.log +0 -48
- package/frontend/astro.config.mjs +0 -35
- package/frontend/public/css/app.css +0 -319
- package/frontend/public/favicon.ico +0 -0
- package/frontend/src/http/api.js +0 -29
- package/frontend/src/layouts/Layout.astro +0 -20
- package/frontend/src/pages/about.astro +0 -54
- package/frontend/src/pages/index.astro +0 -110
package/README.md
CHANGED
|
@@ -1,343 +1,312 @@
|
|
|
1
|
-
# Blue Bird Framework
|
|
2
|
-
|
|
3
|
-
**High-Performance Express Framework — Built for Speed, Caching, and Visual Excellence**
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@seip/blue-bird)
|
|
8
|
-
[](https://opensource.org/licenses/MIT)
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Introduction
|
|
13
|
-
|
|
14
|
-
Blue Bird is a powerful,
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## 🚀 Key Features / Características Clave
|
|
19
|
-
|
|
20
|
-
- All-In-One: Pre-configured Express server with JSON, URL encoding, Cookies, and CORS.
|
|
21
|
-
-
|
|
22
|
-
- Premium Security: AES-256-GCM encrypted JWT cookie auth, secure route filters, and built-in Helmet configurator.
|
|
23
|
-
- File Uploads: Easy Multer-based single/multiple file storage handling.
|
|
24
|
-
- Docker & PM2 Devops: Pre-built Docker Compose/Dockerfile templates and CLI tools for zero-config dev and VPS production.
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## 🛠️ Quick Start / Inicio Rápido
|
|
29
|
-
|
|
30
|
-
### 1. Installation / Instalación
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
npm install @seip/blue-bird
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### 2. Initialize Project / Inicializar
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npx blue-bird
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
│
|
|
62
|
-
│
|
|
63
|
-
|
|
64
|
-
│ ├──
|
|
65
|
-
│
|
|
66
|
-
│
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
├──
|
|
71
|
-
├──
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
```javascript
|
|
161
|
-
import
|
|
162
|
-
|
|
163
|
-
//
|
|
164
|
-
router.get("/
|
|
165
|
-
res.json({
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
-
|
|
244
|
-
-
|
|
245
|
-
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
### B. Standard Standalone PM2 / Node.js Runtime
|
|
314
|
-
|
|
315
|
-
If you choose to run outside of Docker, you must set up the reverse proxy and databases manually. To deploy in a standard Linux environment using PM2:
|
|
316
|
-
|
|
317
|
-
1. Install PM2 globally:
|
|
318
|
-
```bash
|
|
319
|
-
npm install pm2 -g
|
|
320
|
-
```
|
|
321
|
-
2. Start the application under PM2:
|
|
322
|
-
```bash
|
|
323
|
-
pm2 start index.js --name "bluebird-app" --node-args="--env-file=.env" -i max
|
|
324
|
-
```
|
|
325
|
-
3. Monitor status:
|
|
326
|
-
```bash
|
|
327
|
-
pm2 status
|
|
328
|
-
pm2 logs
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
---
|
|
332
|
-
|
|
333
|
-
## 📄 License / Licencia
|
|
334
|
-
|
|
335
|
-
Distributed under the **MIT License**. See `LICENSE` for more information.
|
|
336
|
-
|
|
337
|
-
Distribuido bajo la **Licencia MIT**. Mira `LICENSE` para más información.
|
|
338
|
-
|
|
339
|
-
---
|
|
340
|
-
|
|
341
|
-
<div align="center">
|
|
342
|
-
<p>Made with ❤️ by <strong>Seip25</strong></p>
|
|
343
|
-
</div>
|
|
1
|
+
# Blue Bird Framework
|
|
2
|
+
|
|
3
|
+
**High-Performance Express Framework — Built for Speed, Caching, and Visual Excellence**
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@seip/blue-bird)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Introduction
|
|
13
|
+
|
|
14
|
+
Blue Bird is a powerful, performance-first API framework built on Express. It features pre-configured data validation, security middlewares, GCM-encrypted JWT authentication, and CLI/Docker developer workflows out of the box, with static frontend assets handled directly by Nginx.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 🚀 Key Features / Características Clave
|
|
19
|
+
|
|
20
|
+
- All-In-One: Pre-configured Express API server with JSON, URL encoding, Cookies, and CORS.
|
|
21
|
+
- Nginx Static Frontend: Lightning-fast static asset and extensionless HTML serving via Nginx, decoupled from Node.js.
|
|
22
|
+
- Premium Security: AES-256-GCM encrypted JWT cookie auth, secure route filters, and built-in Helmet configurator.
|
|
23
|
+
- File Uploads: Easy Multer-based single/multiple file storage handling.
|
|
24
|
+
- Docker & PM2 Devops: Pre-built Docker Compose/Dockerfile templates and CLI tools for zero-config dev and VPS production.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🛠️ Quick Start / Inicio Rápido
|
|
29
|
+
|
|
30
|
+
### 1. Installation / Instalación
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @seip/blue-bird
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Initialize Project / Inicializar
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx blue-bird
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
When run, the interactive CLI prompts for your preferred infrastructure configuration:
|
|
43
|
+
- Database Selection: Choose between `none`, `mysql`, or `postgres`.
|
|
44
|
+
- Credentials: Set your database name, user, password, and port (`3306` or `5432`).
|
|
45
|
+
|
|
46
|
+
The CLI intelligently copies the appropriate Docker configuration (`docker/docker-compose.mysql.yml`, `docker/docker-compose.postgres.yml`, or `docker/docker-compose.none.yml`) to your project root as `docker-compose.yml`. It also writes the environment settings (`DB_TYPE`, `DATABASE_URL`) to `.env` and installs the required database packages (`mysql2` or `pg`) automatically.
|
|
47
|
+
|
|
48
|
+
### 3. Run Development Server / Modo Desarrollo
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run dev
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 📁 Project Structure / Estructura del Proyecto
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
project/
|
|
60
|
+
├── backend/
|
|
61
|
+
│ └── routes/ # Express route files
|
|
62
|
+
│ └── api.js # REST API routes
|
|
63
|
+
├── frontend/
|
|
64
|
+
│ ├── css/ # CSS files
|
|
65
|
+
│ ├── js/ # JavaScript files
|
|
66
|
+
│ └── index.html # Static HTML files
|
|
67
|
+
├── docker/
|
|
68
|
+
│ └── Dockerfile # Optimized production build file
|
|
69
|
+
├── docker-compose.yml # Dev/Prod container configurations
|
|
70
|
+
├── index.js # App startup and initialization entrypoint
|
|
71
|
+
├── AGENTS.md # AI coding assistant guidebook
|
|
72
|
+
└── .env # App configuration (git-ignored)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 📖 Core Modules Documentation / Documentación de Módulos
|
|
78
|
+
|
|
79
|
+
### 1. Routing (`Router`)
|
|
80
|
+
|
|
81
|
+
Do not use Express' native router. Always use Blue Bird's wrapper class:
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
import Router from "@seip/blue-bird/core/router.js";
|
|
85
|
+
|
|
86
|
+
const routerApi = new Router("/api");
|
|
87
|
+
routerApi.get("/users", (req, res) => {
|
|
88
|
+
res.json({ users: [] });
|
|
89
|
+
});
|
|
90
|
+
export default routerApi;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
### 3. Data Validation (`Validator`)
|
|
98
|
+
|
|
99
|
+
Validates request payloads using a JSON schema. Returns structured `400 Bad Request` payloads automatically on schema failures.
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
import Validator from "@seip/blue-bird/core/validate.js";
|
|
103
|
+
|
|
104
|
+
const userSchema = {
|
|
105
|
+
email: { required: true, email: true },
|
|
106
|
+
password: { required: true, min: 8 },
|
|
107
|
+
bio: { required: false },
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const validateUser = new Validator(userSchema, "en");
|
|
111
|
+
|
|
112
|
+
routerApi.post("/users", validateUser.middleware(), (req, res) => {
|
|
113
|
+
res.json({ success: true });
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### 4. JWT Authentication (`Auth`)
|
|
120
|
+
|
|
121
|
+
Secure user sessions using stateless AES-256-GCM encrypted JWTs stored in secure HTTP-Only cookies.
|
|
122
|
+
|
|
123
|
+
#### Protecting Routes
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
import Auth from "@seip/blue-bird/core/auth.js";
|
|
127
|
+
|
|
128
|
+
// Secure API endpoint (returns 401 on failure)
|
|
129
|
+
router.get("/profile", Auth.protect(), (req, res) => {
|
|
130
|
+
res.json({ user: req.user });
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Secure web page (redirects to /login on failure)
|
|
134
|
+
router.get("/dashboard", Auth.protect({ redirect: "/login" }), (req, res) => {
|
|
135
|
+
Template.render(res, "dashboard");
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Authentication Sessions
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
router.post("/login", async (req, res) => {
|
|
143
|
+
const user = { id: 1, name: "John Doe" };
|
|
144
|
+
await Auth.login(res, user);
|
|
145
|
+
res.json({ message: "Logged in successfully" });
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
router.post("/logout", async (req, res) => {
|
|
149
|
+
await Auth.logout(res);
|
|
150
|
+
res.json({ message: "Logged out" });
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### 5. Performance Cache Middleware (`Cache`)
|
|
157
|
+
|
|
158
|
+
Applies caching at the route handler level. Automatically caches JSON payloads (`res.json`) and rendered outputs (`res.send`).
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
import Cache from "@seip/blue-bird/core/cache.js";
|
|
162
|
+
|
|
163
|
+
// Cache endpoint for 60 seconds
|
|
164
|
+
router.get("/stats", Cache.middleware(60), (req, res) => {
|
|
165
|
+
res.json({ usersOnline: 42 });
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Integrates with Redis if `REDIS_HOST` is defined in the environment. Falls back to an in-memory cache automatically if Redis is not configured or not running.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### 6. Security Headers (`Helmet`)
|
|
174
|
+
|
|
175
|
+
Apply security headers per-router. Preserves the framework's custom powered-by header by default:
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
import App from "@seip/blue-bird/core/app.js";
|
|
179
|
+
|
|
180
|
+
const webRouter = new Router("/web");
|
|
181
|
+
webRouter.use(App.helmet());
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
### 7. Database wrapper (`Database`)
|
|
187
|
+
|
|
188
|
+
Blue Bird provides a unified, multi-database client wrapper (`core/database.js`) supporting **MySQL** and **PostgreSQL** with automated connection retry loops, query formatting utilities, and Redis query caching.
|
|
189
|
+
|
|
190
|
+
#### Driver Support
|
|
191
|
+
- **Native MySQL (`mysql2/promise`)**: High-performance connection pool for MySQL 8.0+.
|
|
192
|
+
- **Native PostgreSQL (`pg`)**: Connection pool for PostgreSQL 18+. When running standard queries with `connection.query(sql, params)`, the wrapper automatically converts `?` parameter placeholders into PostgreSQL `$1, $2, ...` syntax, allowing unified SQL query writing across both database engines.
|
|
193
|
+
- **No Database (`none`)**: If no database is configured, the wrapper is disabled gracefully without crashing the server.
|
|
194
|
+
|
|
195
|
+
#### Standalone & Remote Database Configuration
|
|
196
|
+
You can connect to any local or remote database instance (outside Docker, such as Supabase, Neon, AWS RDS, or local services) simply by defining the `DATABASE_URL` in your `.env` file:
|
|
197
|
+
|
|
198
|
+
```env
|
|
199
|
+
DB_TYPE="postgres"
|
|
200
|
+
DATABASE_URL="postgresql://postgres:password@localhost:5432/blue_bird?schema=public"
|
|
201
|
+
# OR for MySQL:
|
|
202
|
+
# DATABASE_URL="mysql://root:password@localhost:3306/blue_bird"
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### Usage Examples
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
import { Database, DB_TYPE } from "@seip/blue-bird/core/database.js";
|
|
209
|
+
|
|
210
|
+
// Instantiate the database connection pool with a connection limit (e.g., 20)
|
|
211
|
+
const connection = new Database(20);
|
|
212
|
+
|
|
213
|
+
// 1. Basic SELECT query returning single row (Works for both MySQL and PostgreSQL using ? placeholders)
|
|
214
|
+
const user = await connection.query("SELECT * FROM users WHERE email = ?", ["test@example.com"], "return_row");
|
|
215
|
+
|
|
216
|
+
// 2. Fetch rows with 60 seconds Redis caching enabled
|
|
217
|
+
const stats = await connection.query("SELECT COUNT(*) as count FROM access_logs", [], { cache: 60 });
|
|
218
|
+
|
|
219
|
+
// 3. INSERT query (returns insertId for MySQL, or inserted row ID / rowCount for PostgreSQL)
|
|
220
|
+
const newId = await connection.query("INSERT INTO users (name) VALUES (?)", ["John"]);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
### 8. Nginx Static Asset Caching
|
|
226
|
+
|
|
227
|
+
Nginx is configured to explicitly cache static assets (`.js`, `.css`, `.jpg`, `.png`, etc.) in the user's browser with the `Cache-Control` header (valid for 1 month). HTML and API endpoints (`/api/*`) are not cached by Nginx to ensure they serve dynamic and up-to-date content, relying instead on the Node.js application and Redis for data-layer caching.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Docker CLI Workflow
|
|
232
|
+
|
|
233
|
+
Blue Bird comes with a built-in Docker CLI wrapper that handles both local development database bootstrapping and full-stack VPS production deployments across MySQL, PostgreSQL, or no-database architectures.
|
|
234
|
+
|
|
235
|
+
### Commands Syntax:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
npx blue-bird docker <command> [options]
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Supported Actions:
|
|
242
|
+
|
|
243
|
+
- **`npx blue-bird docker dev`**: Boots the development stack (Node.js App with `npm run dev` + Nginx + Database + Redis).
|
|
244
|
+
- **`npx blue-bird docker start`**: Boots the production stack (Node.js App + Nginx + Database + Redis).
|
|
245
|
+
- **`npx blue-bird docker start db`** (or `postgres` / `mysql`): Boots the configured database container only (great for local development outside Docker).
|
|
246
|
+
- **`npx blue-bird docker start redis`**: Boots the Redis container only.
|
|
247
|
+
- **`npx blue-bird docker start dbs`**: Boots both database containers (configured DB + Redis).
|
|
248
|
+
- **`npx blue-bird docker stop`**: Stops all active project containers.
|
|
249
|
+
- **`npx blue-bird docker build [--no-cache]`**: Builds or updates the Node.js production image.
|
|
250
|
+
- **`npx blue-bird docker ps`**: Lists running project containers and ports.
|
|
251
|
+
- **`npx blue-bird docker logs [app|db|postgres|mysql]`**: Tails logs for the specified container.
|
|
252
|
+
- **`npx blue-bird docker pm2 [args]`**: Runs PM2 commands inside the Node.js application container (e.g. `status`, `monit`, `reload all`).
|
|
253
|
+
- **`npx blue-bird docker db`** (or `psql` / `mysql`): Connects into the container's interactive database shell (`psql` for PostgreSQL, `mysql` for MySQL) using credentials from `.env`.
|
|
254
|
+
- **`npx blue-bird docker redis`**: Connects into the container's interactive Redis CLI terminal.
|
|
255
|
+
- **`npx blue-bird docker prune`**: Safely clears orphaned volumes, dangling build caches, and images.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## 🚀 Production Deployment Options
|
|
260
|
+
|
|
261
|
+
You can deploy Blue Bird applications to production using two main workflows:
|
|
262
|
+
|
|
263
|
+
### A. Docker Container Stack (Highly Recommended)
|
|
264
|
+
|
|
265
|
+
Using the built-in Docker stack is the recommended deployment method because it sets up a complete, hardened production environment automatically:
|
|
266
|
+
- **Nginx Reverse Proxy:** Captures traffic on port 3000 (or custom PORT), serves static assets and extensionless HTML directly from the filesystem to offload the Node.js server, and proxies API traffic to Express.
|
|
267
|
+
- **PM2 Clustering:** Launches Node.js in cluster mode inside the container, utilizing all available CPU cores based on `PM2_INSTANCES` configuration (defaulting to 1).
|
|
268
|
+
- **Security Mitigation:** Nginx blocks common malicious scanners (e.g. `/.env`, `/.git`, `/wp-admin`) instantly using a 444 status code and implements a `10r/s` request rate-limit.
|
|
269
|
+
- **Services Stack:** MySQL and Redis are configured in the same bridge network automatically.
|
|
270
|
+
|
|
271
|
+
To deploy via Docker:
|
|
272
|
+
1. Configure `.env` with production keys, `DEBUG=false` and your custom `TITLE`.
|
|
273
|
+
2. Build the production image:
|
|
274
|
+
```bash
|
|
275
|
+
npx blue-bird docker build
|
|
276
|
+
```
|
|
277
|
+
3. Run the container cluster:
|
|
278
|
+
```bash
|
|
279
|
+
npx blue-bird docker start prod
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### B. Standard Standalone PM2 / Node.js Runtime
|
|
283
|
+
|
|
284
|
+
If you choose to run outside of Docker, you must set up the reverse proxy and databases manually. To deploy in a standard Linux environment using PM2:
|
|
285
|
+
|
|
286
|
+
1. Install PM2 globally:
|
|
287
|
+
```bash
|
|
288
|
+
npm install pm2 -g
|
|
289
|
+
```
|
|
290
|
+
2. Start the application under PM2:
|
|
291
|
+
```bash
|
|
292
|
+
pm2 start index.js --name "bluebird-app" --node-args="--env-file=.env" -i max
|
|
293
|
+
```
|
|
294
|
+
3. Monitor status:
|
|
295
|
+
```bash
|
|
296
|
+
pm2 status
|
|
297
|
+
pm2 logs
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## 📄 License / Licencia
|
|
303
|
+
|
|
304
|
+
Distributed under the **MIT License**. See `LICENSE` for more information.
|
|
305
|
+
|
|
306
|
+
Distribuido bajo la **Licencia MIT**. Mira `LICENSE` para más información.
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
<div align="center">
|
|
311
|
+
<p>Made with ❤️ by <strong>Seip25</strong></p>
|
|
312
|
+
</div>
|