@seip/blue-bird 0.7.6 → 0.9.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.
Files changed (40) hide show
  1. package/.env_example +34 -34
  2. package/AGENTS.md +174 -249
  3. package/LICENSE +21 -21
  4. package/README.md +331 -367
  5. package/{index.js → backend/index.js} +22 -30
  6. package/backend/routes/api.js +57 -57
  7. package/core/app.js +338 -402
  8. package/core/auth.js +262 -256
  9. package/core/cache.js +174 -174
  10. package/core/cli/docker.js +488 -457
  11. package/core/cli/init.js +333 -337
  12. package/core/cli/route.js +42 -42
  13. package/core/config.js +52 -52
  14. package/core/database.js +263 -263
  15. package/core/debug.js +248 -248
  16. package/core/logger.js +115 -115
  17. package/core/middleware.js +27 -27
  18. package/core/router.js +144 -144
  19. package/core/swagger.js +40 -40
  20. package/core/upload.js +77 -77
  21. package/core/validate.js +380 -380
  22. package/docker/Dockerfile +16 -16
  23. package/docker/docker-compose.dev.yml +6 -0
  24. package/docker/docker-compose.mysql.yml +92 -92
  25. package/docker/docker-compose.none.yml +68 -68
  26. package/docker/docker-compose.postgres.yml +93 -93
  27. package/docker/nginx.conf +98 -106
  28. package/docker-compose.yml +92 -92
  29. package/frontend/about.html +103 -0
  30. package/frontend/images/favicon.ico +0 -0
  31. package/frontend/index.html +141 -0
  32. package/frontend/js/tailwind.js +8 -0
  33. package/package.json +64 -71
  34. package/frontend/astro.config.mjs +0 -35
  35. package/frontend/public/css/app.css +0 -319
  36. package/frontend/public/favicon.ico +0 -0
  37. package/frontend/src/http/api.js +0 -29
  38. package/frontend/src/layouts/Layout.astro +0 -20
  39. package/frontend/src/pages/about.astro +0 -54
  40. package/frontend/src/pages/index.astro +0 -110
package/.env_example CHANGED
@@ -1,35 +1,35 @@
1
- # Server and Application Configuration
2
- DEBUG=true
3
- PORT=3000
4
- HOST="localhost"
5
- APP_URL="http://localhost"
6
- VERSION="1.0.0"
7
-
8
- # Docker / Swagger Config
9
- TITLE="Blue-Bird"
10
- DESCRIPTION="Description project"
11
-
12
- # Security Configuration
13
- JWT_SECRET="JWT_SECRET"
14
-
15
- # Redis Configuration
16
- REDIS_HOST="localhost"
17
- REDIS_PORT=6379
18
- REDIS_PASSWORD=""
19
-
20
- # PM2 Clustering Instances (integer or 'max')
21
- PM2_INSTANCES=1
22
-
23
- # Database Configuration (Used only for local development outside Docker)
24
- # MySQL
25
- DATABASE_URL="mysql://root:root@localhost:3306/blue_bird"
26
-
27
- # PostgreSQL (Uncomment to use PostgreSQL locally or DEV)
28
- # DATABASE_URL="postgresql://postgres:root@localhost:5432/blue_bird?schema=public"
29
-
30
- # Database / Docker Configuration
31
- DB_TYPE="mysql"
32
- DB_NAME="blue_bird"
33
- DB_USER="root"
34
- DB_PASSWORD="root"
1
+ # Server and Application Configuration
2
+ DEBUG=true
3
+ PORT=3000
4
+ HOST="localhost"
5
+ APP_URL="http://localhost"
6
+ VERSION="1.0.0"
7
+
8
+ # Docker / Swagger Config
9
+ TITLE="Blue-Bird"
10
+ DESCRIPTION="Description project"
11
+
12
+ # Security Configuration
13
+ JWT_SECRET="JWT_SECRET"
14
+
15
+ # Redis Configuration
16
+ REDIS_HOST="localhost"
17
+ REDIS_PORT=6379
18
+ REDIS_PASSWORD=""
19
+
20
+ # PM2 Clustering Instances (integer or 'max')
21
+ PM2_INSTANCES=1
22
+
23
+ # Database Configuration (Used only for local development outside Docker)
24
+ # MySQL
25
+ DATABASE_URL="mysql://root:root@localhost:3306/blue_bird"
26
+
27
+ # PostgreSQL (Uncomment to use PostgreSQL locally or DEV)
28
+ # DATABASE_URL="postgresql://postgres:root@localhost:5432/blue_bird?schema=public"
29
+
30
+ # Database / Docker Configuration
31
+ DB_TYPE="mysql"
32
+ DB_NAME="blue_bird"
33
+ DB_USER="root"
34
+ DB_PASSWORD="root"
35
35
  DB_PORT=3306
package/AGENTS.md CHANGED
@@ -1,249 +1,174 @@
1
- # Blue Bird Framework - AI Agent Guide
2
-
3
- This document serves as the primary manual for any AI Agent interacting with the codebase. It details the architecture of Blue Bird, its internal modules, and how features should be written or modified.
4
-
5
- ## 1. Core Architecture
6
-
7
- Blue Bird is a framework built on **Express** for backend and **Astro** (v7.0) for frontend rendering. It saves developers from repetitive configuration, validation, security, JWT authentication, and database environment configuration out of the box.
8
-
9
- - **Entrypoint (`index.js`)**: Initializes the server using `App` from `core/app.js` and registers the routes.
10
- - **Backend (`backend/`)**: Application routes and logic (e.g. `backend/routes/`).
11
- - **Frontend (`frontend/`)**: Astro project files. Source pages go in `frontend/src/pages/` and static/public assets go in `frontend/public/`.
12
- - **Core (`core/`)**: The framework core. Contains wrapper classes such as `Router`, `Validator`, `Auth`, `Cache`, etc. **DO NOT MODIFY** the core unless explicitly requested, as it could break other apps.
13
-
14
- ## 2. Routing (Router)
15
-
16
- Do not use Express' native router (`express.Router()`). Always use Blue Bird's `Router` wrapper.
17
-
18
- ```javascript
19
- import Router from "@seip/blue-bird/core/router.js";
20
-
21
- const routerApi = new Router("/api");
22
-
23
- routerApi.get("/users", (req, res) => {
24
- res.json({ users: [] });
25
- });
26
-
27
- export default routerApi;
28
- ```
29
-
30
- Astro routes (pages) are handled automatically by Astro's file-based routing inside the `frontend/src/pages/` directory.
31
-
32
- ## 3. Astro Node Middleware Integration
33
-
34
- Blue Bird integrates Astro as a middleware handler. This is configured in the main `App` constructor:
35
-
36
- ```javascript
37
- import App from "@seip/blue-bird/core/app.js";
38
- import routerApi from "./backend/routes/api.js";
39
-
40
- const app = new App({
41
- routes: [routerApi],
42
- astro: true, // Enables Astro SSR/SSG middleware mode
43
- });
44
-
45
- app.run();
46
- ```
47
-
48
- ### Config Options
49
-
50
- Astro middleware options can be customized by passing a configuration object:
51
-
52
- ```javascript
53
- const app = new App({
54
- astro: {
55
- server: true, // Enables Astro SSR handler middleware
56
- serverEntry: "./frontend/dist/server/entry.mjs", // Path to server build entrypoint
57
- client: false, // Set to true to serve Astro client static assets
58
- clientDir: "./frontend/dist/client", // Path to client static build folder
59
- base: "/" // Base route mount path
60
- }
61
- });
62
- ```
63
-
64
- To use Astro as Express middleware, ensure your Astro configuration uses the node adapter in middleware mode:
65
-
66
- ```javascript
67
- // frontend/astro.config.mjs
68
- import { defineConfig } from 'astro/config';
69
- import node from '@astrojs/node';
70
-
71
- export default defineConfig({
72
- output: 'server',
73
- adapter: node({
74
- mode: 'middleware',
75
- }),
76
- });
77
- ```
78
-
79
- ## 4. Data Validation (Validator)
80
-
81
- Incoming request data must be validated using `core/validate.js`, which automatically returns HTTP 400 JSON responses on error.
82
-
83
- ```javascript
84
- import Validator from "@seip/blue-bird/core/validate.js";
85
-
86
- const userSchema = {
87
- email: { required: true, email: true },
88
- password: { required: true, min: 8 },
89
- bio: { required: false },
90
- };
91
-
92
- const validateUser = new Validator(userSchema, "en");
93
-
94
- routerApi.post("/users", validateUser.middleware(), (req, res) => {
95
- res.json({ success: true });
96
- });
97
- ```
98
-
99
- ## 5. Authentication (Auth)
100
-
101
- The system includes built-in JWT handling with AES-256-GCM encryption. The framework handles tokens via Cookies or the `Authorization` header.
102
-
103
- ### Protecting Routes
104
-
105
- Use `Auth.protect()` as a middleware to secure routes.
106
-
107
- ```javascript
108
- import Auth from "@seip/blue-bird/core/auth.js";
109
-
110
- router.get("/profile", Auth.protect(), (req, res) => {
111
- res.json({ user: req.user });
112
- });
113
- ```
114
-
115
- ### Login and Logout
116
-
117
- The `Auth` class provides helpers to handle session management via cookies.
118
-
119
- ```javascript
120
- router.post("/login", async (req, res) => {
121
- const user = { id: 1, name: "John" };
122
- await Auth.login(res, user);
123
- res.json({ message: "Logged in" });
124
- });
125
-
126
- router.post("/logout", async (req, res) => {
127
- await Auth.logout(res);
128
- res.json({ message: "Logged out" });
129
- });
130
- ```
131
-
132
- ## 6. Performance Caching (Cache)
133
-
134
- If an Express route involves heavy processing or database queries, utilize the `Cache` middleware to cache the REST API JSON or HTML payload.
135
-
136
- ```javascript
137
- import Cache from "@seip/blue-bird/core/cache.js";
138
-
139
- router.get("/stats", Cache.middleware(60), (req, res) => {
140
- res.json({ ok: true });
141
- });
142
- ```
143
-
144
- The Cache module integrates with Redis when `REDIS_HOST` is configured in the environment. If Redis is unavailable or fails, it transparently falls back to an in-memory cache system without interrupting requests.
145
-
146
- ## 7. Security (Helmet)
147
-
148
- Helmet is **not applied globally** by default. Apply it per-router where needed:
149
-
150
- ```javascript
151
- import App from "@seip/blue-bird/core/app.js";
152
-
153
- const apiRouter = new Router("/api");
154
- apiRouter.use(App.helmet());
155
- ```
156
-
157
- ## 8. Docker Compose CLI
158
-
159
- Blue Bird features a built-in Docker Compose CLI wrapper (`core/cli/docker.js`) to deploy and manage containerized development databases and production stacks across MySQL, PostgreSQL, or no-database (`none`) architectures.
160
-
161
- Production deployments always use Docker for orchestration, running:
162
- - Nginx: Serves static files directly from `frontend/dist/client/` and blocks common scanner requests (`.env`, `.git`, etc.) with fallback to Express.
163
- - Node.js App: Managed via PM2 in cluster mode using `PM2_INSTANCES` configuration (defaults to `1`, can be set to `max`).
164
- - Database: MySQL (`mysql:8.0`) or PostgreSQL (`postgres:18-alpine`), dynamically detected via `getDbType()` reading `DB_TYPE` / `DATABASE_URL` from `.env`.
165
- - Redis: Memory caching and session store.
166
-
167
- ```bash
168
- # Manage containers using blue-bird CLI
169
- npx blue-bird docker start # Starts production app stack (DB, redis, app, nginx)
170
- npx blue-bird docker start db # Starts configured database container only (postgres or mysql)
171
- npx blue-bird docker start redis # Starts Redis container only
172
- npx blue-bird docker start dbs # Starts both database containers (configured DB + Redis)
173
- npx blue-bird docker stop # Stops all running containers
174
- npx blue-bird docker build # Builds/rebuilds application image
175
- npx blue-bird docker ps # Shows status of active containers
176
- npx blue-bird docker logs # Tails Node.js app container logs
177
- npx blue-bird docker logs db # Tails configured database container logs
178
- npx blue-bird docker pm2 [args] # Runs PM2 commands inside the app container (e.g. status, monit)
179
- npx blue-bird docker db # Runs interactive shell inside container (psql for Postgres, mysql for MySQL)
180
- npx blue-bird docker psql # Runs interactive PostgreSQL client terminal inside container
181
- npx blue-bird docker mysql # Runs interactive MySQL client terminal inside container
182
- npx blue-bird docker redis # Runs interactive Redis client terminal inside container
183
- npx blue-bird docker prune # Cleans unused volumes, dangling images, and BuildKit caches
184
- ```
185
-
186
- The container names and virtual networks are namespaced by the `TITLE` environment variable parsed from `.env` to prevent resource collisions on VPS hosts. Alternatively, PM2 and other services can be run manually in standalone server environments by configuring `DATABASE_URL` inside `.env`.
187
-
188
- ## 9. AI Development Guidelines
189
-
190
- 1. **Frontend**: Use Astro pages inside `frontend/src/pages/` (e.g. `.astro` files). Static/public assets belong in `frontend/public/`.
191
- 2. **JSON Responses**: API endpoints should return standardized responses formatted as `{ message: "..." }` or `{ data: ... }`.
192
- 3. **Magic Imports**: Stick to pure relative imports or well-configured aliases (imports natively resolve from `@seip/blue-bird/...` or relative directories like `../../`).
193
- 4. **No inline comments**: Only use JSDoc for documentation.
194
-
195
- ## 10. Database Module (database.js)
196
-
197
- Blue Bird provides a unified wrapper class (`core/database.js`) supporting **MySQL (`mysql2/promise`)** and **PostgreSQL (`pg`)**. It features connection pooling, automatic retries on startup, query formatting, and built-in Redis query caching:
198
-
199
- - **Dynamic Initialization:** When `npx blue-bird` (`core/cli/init.js`) runs, it prompts the developer for the database type (`none`, `mysql`, `postgres`). It then intelligently copies the correct `docker-compose.yml` template (`docker-compose.mysql.yml`, `docker-compose.postgres.yml`, or `docker-compose.none.yml`) and configures `.env` with `DB_TYPE` and `DATABASE_URL`.
200
- - **Parameter Placeholders:** When using `pg` for PostgreSQL with `connection.query()`, `?` placeholders are automatically translated to `$1, $2, ...` under the hood.
201
-
202
- ```javascript
203
- import { Database, DB_TYPE } from "@seip/blue-bird/core/database.js";
204
-
205
- const connection = new Database(20);
206
-
207
- // Basic SELECT query returning single row (Supports both MySQL and PostgreSQL)
208
- const user = await connection.query("SELECT * FROM users WHERE id = ?", [1], "return_row");
209
-
210
- // Query caching in Redis (stores results in Redis for 60 seconds)
211
- const stats = await connection.query("SELECT COUNT(*) as cnt FROM logs", [], { cache: 60 });
212
-
213
- // INSERT query returns insertId directly (or row ID/rowCount in Postgres)
214
- const newUserId = await connection.query("INSERT INTO users (name) VALUES (?)", ["Alice"]);
215
- ```
216
-
217
- ## 11. Nginx Proxy Caching
218
-
219
- In production, Nginx caches Astro page responses for 10 seconds. Requests with an active session cookie (`auth`) or `Authorization` header bypass the cache to ensure dynamic page personalized output.
220
-
221
- ### Disabling Cache
222
-
223
- To disable Nginx proxy caching, comment out the `proxy_cache` directives in `docker/nginx.conf`:
224
-
225
- ```nginx
226
- # proxy_cache astro_cache;
227
- # proxy_cache_valid 200 302 10s;
228
- ```
229
-
230
- ### Caching API routes
231
-
232
- To cache specific GET API routes at the proxy layer (which is faster and consumes less resources than Node/Redis query caching), define a specific location block in `docker/nginx.conf` before the generic `/api/` routing rule:
233
-
234
- ```nginx
235
- location /api/cached-endpoint {
236
- limit_req zone=bluebird_limit burst=20 nodelay;
237
- set $upstream_target http://app:3000;
238
- proxy_pass $upstream_target;
239
- proxy_http_version 1.1;
240
- proxy_set_header Connection "";
241
- proxy_set_header Host $host;
242
-
243
- proxy_cache astro_cache;
244
- proxy_cache_valid 200 10s;
245
- add_header X-Cache-Status $upstream_cache_status;
246
- }
247
- ```
248
-
249
- _This file can be retrieved by intelligent agents reading its absolute physical path during reasoning._
1
+ # Blue Bird Framework - AI Agent Guide
2
+
3
+ This document serves as the primary manual for any AI Agent interacting with the codebase. It details the architecture of Blue Bird, its internal modules, and how features should be written or modified.
4
+
5
+ ## 1. Core Architecture
6
+
7
+ Blue Bird is a performance-first API framework built on **Express**. It saves developers from repetitive configuration, validation, security, JWT authentication, and database environment configuration out of the box, delegating all static frontend rendering to Nginx.
8
+
9
+ - **Entrypoint (`index.js`)**: Initializes the server using `App` from `core/app.js` and registers the routes.
10
+ - **Backend (`backend/`)**: Application routes and logic (e.g. `backend/routes/`).
11
+ - **Frontend (`frontend/`)**: Static assets (HTML, CSS, JS). Handled directly by Nginx in production, bypassing Express.
12
+ - **Core (`core/`)**: The framework core. Contains wrapper classes such as `Router`, `Validator`, `Auth`, `Cache`, etc. **DO NOT MODIFY** the core unless explicitly requested, as it could break other apps.
13
+
14
+ ## 2. Routing (Router)
15
+
16
+ Do not use Express' native router (`express.Router()`). Always use Blue Bird's `Router` wrapper.
17
+
18
+ ```javascript
19
+ import Router from "@seip/blue-bird/core/router.js";
20
+
21
+ const routerApi = new Router("/api");
22
+
23
+ routerApi.get("/users", (req, res) => {
24
+ res.json({ users: [] });
25
+ });
26
+
27
+ export default routerApi;
28
+ ```
29
+
30
+
31
+
32
+ Incoming request data must be validated using `core/validate.js`, which automatically returns HTTP 400 JSON responses on error.
33
+
34
+ ```javascript
35
+ import Validator from "@seip/blue-bird/core/validate.js";
36
+
37
+ const userSchema = {
38
+ email: { required: true, email: true },
39
+ password: { required: true, min: 8 },
40
+ bio: { required: false },
41
+ };
42
+
43
+ const validateUser = new Validator(userSchema, "en");
44
+
45
+ routerApi.post("/users", validateUser.middleware(), (req, res) => {
46
+ res.json({ success: true });
47
+ });
48
+ ```
49
+
50
+ ## 5. Authentication (Auth)
51
+
52
+ The system includes built-in JWT handling with AES-256-GCM encryption. The framework handles tokens via Cookies or the `Authorization` header.
53
+
54
+ ### Protecting Routes
55
+
56
+ Use `Auth.protect()` as a middleware to secure routes.
57
+
58
+ ```javascript
59
+ import Auth from "@seip/blue-bird/core/auth.js";
60
+
61
+ router.get("/profile", Auth.protect(), (req, res) => {
62
+ res.json({ user: req.user });
63
+ });
64
+ ```
65
+
66
+ ### Login and Logout
67
+
68
+ The `Auth` class provides helpers to handle session management via cookies.
69
+
70
+ ```javascript
71
+ router.post("/login", async (req, res) => {
72
+ const user = { id: 1, name: "John" };
73
+ await Auth.login(res, user);
74
+ res.json({ message: "Logged in" });
75
+ });
76
+
77
+ router.post("/logout", async (req, res) => {
78
+ await Auth.logout(res);
79
+ res.json({ message: "Logged out" });
80
+ });
81
+ ```
82
+
83
+ ## 6. Performance Caching (Cache)
84
+
85
+ If an Express route involves heavy processing or database queries, utilize the `Cache` middleware to cache the REST API JSON or HTML payload.
86
+
87
+ ```javascript
88
+ import Cache from "@seip/blue-bird/core/cache.js";
89
+
90
+ router.get("/stats", Cache.middleware(60), (req, res) => {
91
+ res.json({ ok: true });
92
+ });
93
+ ```
94
+
95
+ The Cache module integrates with Redis when `REDIS_HOST` is configured in the environment. If Redis is unavailable or fails, it transparently falls back to an in-memory cache system without interrupting requests.
96
+
97
+ ## 7. Security (Helmet)
98
+
99
+ Helmet is **not applied globally** by default. Apply it per-router where needed:
100
+
101
+ ```javascript
102
+ import App from "@seip/blue-bird/core/app.js";
103
+
104
+ const apiRouter = new Router("/api");
105
+ apiRouter.use(App.helmet());
106
+ ```
107
+
108
+ ## 8. Docker Compose CLI
109
+
110
+ Blue Bird features a built-in Docker Compose CLI wrapper (`core/cli/docker.js`) to deploy and manage containerized development databases and production stacks across MySQL, PostgreSQL, or no-database (`none`) architectures.
111
+
112
+ Production deployments always use Docker for orchestration, running:
113
+ - Nginx: Serves static files directly from `frontend/` (stripping `.html` extensions) and blocks common scanner requests (`.env`, `.git`, etc.) with fallback to Express for APIs.
114
+ - Node.js App: Managed via PM2 in cluster mode using `PM2_INSTANCES` configuration (defaults to `1`, can be set to `max`).
115
+ - Database: MySQL (`mysql:8.0`) or PostgreSQL (`postgres:18-alpine`), dynamically detected via `getDbType()` reading `DB_TYPE` / `DATABASE_URL` from `.env`.
116
+ - Redis: Memory caching and session store.
117
+
118
+ ```bash
119
+ # Manage containers using blue-bird CLI
120
+ npx blue-bird docker dev # Starts development app stack (DB, redis, app, nginx) with npm run dev
121
+ npx blue-bird docker start # Starts production app stack (DB, redis, app, nginx)
122
+ npx blue-bird docker start db # Starts configured database container only (postgres or mysql)
123
+ npx blue-bird docker start redis # Starts Redis container only
124
+ npx blue-bird docker start dbs # Starts both database containers (configured DB + Redis)
125
+ npx blue-bird docker stop # Stops all running containers
126
+ npx blue-bird docker build # Builds/rebuilds application image
127
+ npx blue-bird docker ps # Shows status of active containers
128
+ npx blue-bird docker logs # Tails Node.js app container logs
129
+ npx blue-bird docker logs db # Tails configured database container logs
130
+ npx blue-bird docker pm2 [args] # Runs PM2 commands inside the app container (e.g. status, monit)
131
+ npx blue-bird docker db # Runs interactive shell inside container (psql for Postgres, mysql for MySQL)
132
+ npx blue-bird docker psql # Runs interactive PostgreSQL client terminal inside container
133
+ npx blue-bird docker mysql # Runs interactive MySQL client terminal inside container
134
+ npx blue-bird docker redis # Runs interactive Redis client terminal inside container
135
+ npx blue-bird docker prune # Cleans unused volumes, dangling images, and BuildKit caches
136
+ ```
137
+
138
+ The container names and virtual networks are namespaced by the `TITLE` environment variable parsed from `.env` to prevent resource collisions on VPS hosts. Alternatively, PM2 and other services can be run manually in standalone server environments by configuring `DATABASE_URL` inside `.env`.
139
+
140
+ ## 9. AI Development Guidelines
141
+
142
+ 1. **Frontend**: Static files are stored in `frontend/` (e.g. `frontend/css`, `frontend/js`). HTML files will be served without the `.html` extension (e.g. `login.html` is accessible as `/login`).
143
+ 2. **JSON Responses**: API endpoints should return standardized responses formatted as `{ message: "..." }` or `{ data: ... }`.
144
+ 3. **Magic Imports**: Stick to pure relative imports or well-configured aliases (imports natively resolve from `@seip/blue-bird/...` or relative directories like `../../`).
145
+ 4. **No inline comments**: Only use JSDoc for documentation.
146
+
147
+ ## 10. Database Module (database.js)
148
+
149
+ Blue Bird provides a unified wrapper class (`core/database.js`) supporting **MySQL (`mysql2/promise`)** and **PostgreSQL (`pg`)**. It features connection pooling, automatic retries on startup, query formatting, and built-in Redis query caching:
150
+
151
+ - **Dynamic Initialization:** When `npx blue-bird` (`core/cli/init.js`) runs, it prompts the developer for the database type (`none`, `mysql`, `postgres`). It then intelligently copies the correct `docker-compose.yml` template (`docker-compose.mysql.yml`, `docker-compose.postgres.yml`, or `docker-compose.none.yml`) and configures `.env` with `DB_TYPE` and `DATABASE_URL`.
152
+ - **Parameter Placeholders:** When using `pg` for PostgreSQL with `connection.query()`, `?` placeholders are automatically translated to `$1, $2, ...` under the hood.
153
+
154
+ ```javascript
155
+ import { Database, DB_TYPE } from "@seip/blue-bird/core/database.js";
156
+
157
+ const connection = new Database(20);
158
+
159
+ // Basic SELECT query returning single row (Supports both MySQL and PostgreSQL)
160
+ const user = await connection.query("SELECT * FROM users WHERE id = ?", [1], "return_row");
161
+
162
+ // Query caching in Redis (stores results in Redis for 60 seconds)
163
+ const stats = await connection.query("SELECT COUNT(*) as cnt FROM logs", [], { cache: 60 });
164
+
165
+ // INSERT query returns insertId directly (or row ID/rowCount in Postgres)
166
+ const newUserId = await connection.query("INSERT INTO users (name) VALUES (?)", ["Alice"]);
167
+ ```
168
+
169
+ ## 11. Nginx Static Asset Caching
170
+
171
+ In production, 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).
172
+ 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.
173
+
174
+ _This file can be retrieved by intelligent agents reading its absolute physical path during reasoning._
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Andres Paiva
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andres Paiva
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.