@shohaghinfo/aerojs 0.1.1 → 0.2.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/AEROJS.md +12 -12
- package/AGENTS.md +709 -709
- package/README.md +181 -7
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +337 -344
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/new.js +51 -51
- package/dist/cli/runner.d.ts.map +1 -1
- package/dist/cli/runner.js +16 -2
- package/dist/cli/runner.js.map +1 -1
- package/dist/cli/templates/fullstack-templates.d.ts +3 -7
- package/dist/cli/templates/fullstack-templates.d.ts.map +1 -1
- package/dist/cli/templates/fullstack-templates.js +540 -13
- package/dist/cli/templates/fullstack-templates.js.map +1 -1
- package/dist/http/http.d.ts +44 -0
- package/dist/http/http.d.ts.map +1 -0
- package/dist/http/http.js +132 -0
- package/dist/http/http.js.map +1 -0
- package/dist/http/index.d.ts +8 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +8 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/request-builder.d.ts +48 -0
- package/dist/http/request-builder.d.ts.map +1 -0
- package/dist/http/request-builder.js +186 -0
- package/dist/http/request-builder.js.map +1 -0
- package/dist/http/response.d.ts +34 -0
- package/dist/http/response.d.ts.map +1 -0
- package/dist/http/response.js +77 -0
- package/dist/http/response.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/mail/drivers/smtp-mail-driver.d.ts +39 -0
- package/dist/mail/drivers/smtp-mail-driver.d.ts.map +1 -0
- package/dist/mail/drivers/smtp-mail-driver.js +318 -0
- package/dist/mail/drivers/smtp-mail-driver.js.map +1 -0
- package/dist/mail/index.d.ts +1 -0
- package/dist/mail/index.d.ts.map +1 -1
- package/dist/mail/index.js +1 -0
- package/dist/mail/index.js.map +1 -1
- package/dist/mail/mailer.d.ts +20 -3
- package/dist/mail/mailer.d.ts.map +1 -1
- package/dist/mail/mailer.js +28 -1
- package/dist/mail/mailer.js.map +1 -1
- package/dist/queue/drivers/redis-queue-driver.d.ts +20 -0
- package/dist/queue/drivers/redis-queue-driver.d.ts.map +1 -1
- package/dist/queue/drivers/redis-queue-driver.js +92 -33
- package/dist/queue/drivers/redis-queue-driver.js.map +1 -1
- package/dist/queue/queue-manager.d.ts +4 -1
- package/dist/queue/queue-manager.d.ts.map +1 -1
- package/dist/queue/queue-manager.js +8 -1
- package/dist/queue/queue-manager.js.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1 -1
- package/dist/security/index.js.map +1 -1
- package/dist/security/rate-limiter.d.ts +20 -0
- package/dist/security/rate-limiter.d.ts.map +1 -1
- package/dist/security/rate-limiter.js +85 -0
- package/dist/security/rate-limiter.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
### The Blazing-Fast, Zero-Dependency Full-Stack Web Framework for Node.js
|
|
6
6
|
|
|
7
7
|
[](https://github.com/atifsoftware/AeroJS/actions/workflows/ci.yml)
|
|
8
|
-
[](https://www.npmjs.com/package/@shohaghinfo/aerojs)
|
|
9
|
+
[](https://www.npmjs.com/package/@shohaghinfo/aerojs)
|
|
9
10
|
[](package.json)
|
|
10
11
|
[](package.json)
|
|
11
12
|
[](package.json)
|
|
@@ -57,6 +58,10 @@
|
|
|
57
58
|
28. [Background Queue & Mail System (`Queue`, `Mail`)](#28-background-queue--mail-system-queue-mail)
|
|
58
59
|
29. [OpenAPI 3.0 & Interactive Swagger UI (`useSwagger`)](#29-openapi-30--interactive-swagger-ui-useswagger)
|
|
59
60
|
30. [Aero Command-Line Interface (`aero` CLI)](#30-aero-command-line-interface-aero-cli)
|
|
61
|
+
31. [SMTP Mail Driver (`SmtpMailDriver`, `Mail`)](#31-smtp-mail-driver-smtpmaildriver-mail)
|
|
62
|
+
32. [Distributed Redis Rate Limiter (`RedisRateLimitStore`)](#32-distributed-redis-rate-limiter-redisratelimitstore)
|
|
63
|
+
33. [Redis Queue Driver with DLQ (`RedisQueueDriver`)](#33-redis-queue-driver-with-dlq-redisqueuedriver)
|
|
64
|
+
34. [Fluent HTTP Client (`Http`, `HttpResponse`)](#34-fluent-http-client-http-httpresponse)
|
|
60
65
|
- [Performance, Size & Advantages](#-performance-size--advantages)
|
|
61
66
|
- [Comparison Matrix](#-comparison-matrix)
|
|
62
67
|
- [License](#-license)
|
|
@@ -146,13 +151,50 @@ Aero is engineered from first principles to combine the best architectural conce
|
|
|
146
151
|
|
|
147
152
|
## 📦 Installation
|
|
148
153
|
|
|
154
|
+
### Option 1: Create a New Project (Recommended)
|
|
155
|
+
|
|
156
|
+
Scaffold a complete production-ready application in seconds using `npx`:
|
|
157
|
+
|
|
149
158
|
```bash
|
|
150
|
-
|
|
159
|
+
# Interactive project creation
|
|
160
|
+
npx @shohaghinfo/aerojs new my-app
|
|
161
|
+
|
|
162
|
+
# Or scaffold in current directory
|
|
163
|
+
npx @shohaghinfo/aerojs init
|
|
151
164
|
```
|
|
152
165
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
166
|
+
### Option 2: Install into an Existing Project
|
|
167
|
+
|
|
168
|
+
Add AeroJS to your project with your favorite package manager:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# npm
|
|
172
|
+
npm install @shohaghinfo/aerojs
|
|
173
|
+
|
|
174
|
+
# pnpm
|
|
175
|
+
pnpm add @shohaghinfo/aerojs
|
|
176
|
+
|
|
177
|
+
# yarn
|
|
178
|
+
yarn add @shohaghinfo/aerojs
|
|
179
|
+
|
|
180
|
+
# bun
|
|
181
|
+
bun add @shohaghinfo/aerojs
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Option 3: Global CLI Installation
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm install -g @shohaghinfo/aerojs
|
|
188
|
+
|
|
189
|
+
# Now you can use the 'aero' command anywhere:
|
|
190
|
+
aero new my-app
|
|
191
|
+
# or
|
|
192
|
+
aerojs new my-app
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Requirements:
|
|
196
|
+
- **Node.js**: `>= 20.0.0`
|
|
197
|
+
- **Module System**: ESM (`"type": "module"` in `package.json`)
|
|
156
198
|
|
|
157
199
|
---
|
|
158
200
|
|
|
@@ -1145,7 +1187,7 @@ Unlike legacy Node.js frameworks that ship with bloated dependency trees, AeroJS
|
|
|
1145
1187
|
- Ideal for **Serverless environments** (AWS Lambda, Cloudflare Containers, Vercel Serverless, Google Cloud Run) and autoscaling Docker microservices.
|
|
1146
1188
|
|
|
1147
1189
|
#### 🏎️ Lightning-Fast CI/CD Deployments
|
|
1148
|
-
- `npm install
|
|
1190
|
+
- `npm install @shohaghinfo/aerojs` downloads only a few kilobytes and completes in **1–2 seconds**, drastically cutting down pipeline build times and bandwidth costs.
|
|
1149
1191
|
|
|
1150
1192
|
#### 🌐 Unified Full-Stack Architecture
|
|
1151
1193
|
- Eliminates context switching and multi-repository overhead: build **REST APIs**, **React/Vue 3 SPAs (Inertia.js)**, and traditional **SSR Views (Edge.js/EJS)** in a single cohesive codebase.
|
|
@@ -1155,9 +1197,141 @@ Unlike legacy Node.js frameworks that ship with bloated dependency trees, AeroJS
|
|
|
1155
1197
|
|
|
1156
1198
|
---
|
|
1157
1199
|
|
|
1200
|
+
### 31. SMTP Mail Driver (`SmtpMailDriver`, `Mail`)
|
|
1201
|
+
|
|
1202
|
+
AeroJS includes a **zero-dependency native SMTP transport** directly built on Node.js `net` and `tls` sockets. Supports SSL (port 465), STARTTLS (port 587/25), AUTH LOGIN, multipart HTML & plain text, and base64 attachments.
|
|
1203
|
+
|
|
1204
|
+
```typescript
|
|
1205
|
+
import { Mail, MailMessage, SmtpMailDriver } from '@shohaghinfo/aerojs';
|
|
1206
|
+
|
|
1207
|
+
// 1. Configure in MailManager
|
|
1208
|
+
Mail.configure({
|
|
1209
|
+
default: 'smtp',
|
|
1210
|
+
mailers: {
|
|
1211
|
+
smtp: {
|
|
1212
|
+
driver: 'smtp',
|
|
1213
|
+
host: 'smtp.mailtrap.io',
|
|
1214
|
+
port: 587,
|
|
1215
|
+
auth: {
|
|
1216
|
+
user: process.env.SMTP_USER!,
|
|
1217
|
+
pass: process.env.SMTP_PASS!,
|
|
1218
|
+
},
|
|
1219
|
+
},
|
|
1220
|
+
},
|
|
1221
|
+
});
|
|
1222
|
+
|
|
1223
|
+
// 2. Dispatch with attachments & HTML
|
|
1224
|
+
await Mail.send((msg) => {
|
|
1225
|
+
msg.to('patient@example.com')
|
|
1226
|
+
.from('billing@hospital.org', 'Hospital Billing')
|
|
1227
|
+
.subject('Monthly Statement & Invoice')
|
|
1228
|
+
.html('<h1>Hello!</h1><p>Please find your medical invoice attached.</p>')
|
|
1229
|
+
.attach('invoice.pdf', pdfBuffer, 'application/pdf');
|
|
1230
|
+
});
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
---
|
|
1234
|
+
|
|
1235
|
+
### 32. Distributed Redis Rate Limiter (`RedisRateLimitStore`)
|
|
1236
|
+
|
|
1237
|
+
For distributed production deployments running behind reverse proxies or multiple server nodes, `RedisRateLimitStore` synchronizes rate limit counters across all instances via atomic Redis commands.
|
|
1238
|
+
|
|
1239
|
+
```typescript
|
|
1240
|
+
import { Aero, rateLimit, RedisRateLimitStore, RedisClient } from '@shohaghinfo/aerojs';
|
|
1241
|
+
|
|
1242
|
+
const app = new Aero();
|
|
1243
|
+
const redis = new RedisClient({ host: '127.0.0.1', port: 6379 });
|
|
1244
|
+
|
|
1245
|
+
app.use(
|
|
1246
|
+
rateLimit({
|
|
1247
|
+
windowMs: 60_000, // 1 minute
|
|
1248
|
+
max: 100, // 100 requests per minute
|
|
1249
|
+
store: new RedisRateLimitStore({
|
|
1250
|
+
client: redis,
|
|
1251
|
+
prefix: 'rl:api:',
|
|
1252
|
+
fallbackToMemory: true, // Gracefully handles Redis disconnection
|
|
1253
|
+
}),
|
|
1254
|
+
})
|
|
1255
|
+
);
|
|
1256
|
+
```
|
|
1257
|
+
|
|
1258
|
+
---
|
|
1259
|
+
|
|
1260
|
+
### 33. Redis Queue Driver with DLQ (`RedisQueueDriver`)
|
|
1261
|
+
|
|
1262
|
+
AeroJS provides a production-grade background job queue backed by Redis with FIFO execution (`LPUSH`/`RPOP`), delayed scheduling (`ZADD`), worker reservation tracking, retry backoff, and a Dead Letter Queue (DLQ).
|
|
1263
|
+
|
|
1264
|
+
```typescript
|
|
1265
|
+
import { Queue, Job, RedisQueueDriver, RedisClient } from '@shohaghinfo/aerojs';
|
|
1266
|
+
|
|
1267
|
+
// 1. Configure Redis Queue Connection
|
|
1268
|
+
Queue.configure({
|
|
1269
|
+
default: 'redis',
|
|
1270
|
+
connections: {
|
|
1271
|
+
redis: {
|
|
1272
|
+
driver: 'redis',
|
|
1273
|
+
redis: new RedisClient({ host: '127.0.0.1', port: 6379 }),
|
|
1274
|
+
},
|
|
1275
|
+
},
|
|
1276
|
+
});
|
|
1277
|
+
|
|
1278
|
+
// 2. Define Background Job
|
|
1279
|
+
class ProcessPayrollJob extends Job {
|
|
1280
|
+
public async handle(): Promise<void> {
|
|
1281
|
+
console.log(`Processing payroll batch #${this.data.batchId}...`);
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
Queue.registerJob('ProcessPayrollJob', ProcessPayrollJob);
|
|
1285
|
+
|
|
1286
|
+
// 3. Dispatch Job (Immediate or Delayed)
|
|
1287
|
+
await Queue.dispatch(new ProcessPayrollJob({ batchId: 402 }), {
|
|
1288
|
+
delay: 10, // Wait 10 seconds before execution
|
|
1289
|
+
});
|
|
1290
|
+
|
|
1291
|
+
// 4. Start Worker
|
|
1292
|
+
const worker = Queue.createWorker({ concurrency: 5 });
|
|
1293
|
+
await worker.start();
|
|
1294
|
+
```
|
|
1295
|
+
|
|
1296
|
+
---
|
|
1297
|
+
|
|
1298
|
+
### 34. Fluent HTTP Client (`Http`, `HttpResponse`)
|
|
1299
|
+
|
|
1300
|
+
AeroJS ships with a powerful, zero-dependency fluent HTTP client built on native `fetch`. It supports automatic JSON serialization, query string formatting, Bearer/Basic authentication, timeouts, retries, and comprehensive testing fakes.
|
|
1301
|
+
|
|
1302
|
+
```typescript
|
|
1303
|
+
import { Http } from '@shohaghinfo/aerojs';
|
|
1304
|
+
|
|
1305
|
+
// 1. Fluent API calls
|
|
1306
|
+
const response = await Http.baseUrl('https://api.hospital-network.com/v1')
|
|
1307
|
+
.withToken(process.env.API_KEY!)
|
|
1308
|
+
.withQuery({ status: 'active', limit: 50 })
|
|
1309
|
+
.timeout(5000)
|
|
1310
|
+
.retry(3, 200)
|
|
1311
|
+
.get('/patients');
|
|
1312
|
+
|
|
1313
|
+
if (response.successful) {
|
|
1314
|
+
const patients = response.json();
|
|
1315
|
+
console.log('Patients fetched:', patients);
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
// 2. Testing Fakes (Mocking external services)
|
|
1319
|
+
Http.fake({
|
|
1320
|
+
'/patients': [{ id: 1, name: 'Alice Smith' }],
|
|
1321
|
+
'/billing': Http.response({ invoiceId: 'INV-101' }, 201),
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
const res = await Http.post('https://api.hospital-network.com/v1/billing', { amount: 500 });
|
|
1325
|
+
expect(res.status).toBe(201);
|
|
1326
|
+
|
|
1327
|
+
Http.assertSent((req) => req.url.includes('/billing') && req.method === 'POST');
|
|
1328
|
+
```
|
|
1329
|
+
|
|
1330
|
+
---
|
|
1331
|
+
|
|
1158
1332
|
## 📊 Comparison Matrix
|
|
1159
1333
|
|
|
1160
|
-
| Feature | Express | Koa | Fastify | AdonisJS | **
|
|
1334
|
+
| Feature | Express | Koa | Fastify | AdonisJS | **AeroJS** |
|
|
1161
1335
|
|---|:---:|:---:|:---:|:---:|:---:|
|
|
1162
1336
|
| **Zero Runtime Dependencies** | ❌ (30+) | ❌ (20+) | ❌ (15+) | ❌ (50+) | **✅ ZERO** |
|
|
1163
1337
|
| **Radix Tree Routing** | ❌ | ❌ | ✅ | ❌ | **✅ O(k)** |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC;CAChC;AAOD,wBAAgB,WAAW,CAAC,eAAe,SAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,MAAM,EAAE,CA+d7F"}
|